Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
February 07, 2011 [Issue 5540] New: Probable bug-hiding redundancies | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5540 Summary: Probable bug-hiding redundancies Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2011-02-07 12:33:29 PST --- This is a real bug in good C++ code: if ((p_newHeader.frame_num != m_lastSlice.frame_num) || (p_newHeader.pic_parameter_set_id != p_newHeader.pic_parameter_set_id) || (p_newHeader.field_pic_flag != p_newHeader.field_pic_flag) || (p_newHeader.bottom_field_flag != m_lastSlice.bottom_field_flag) ){ return false; } The bug is of the kind: if (x != x) {} Two other similar bugs: if (x == x) {} auto y = x - x; For the compiler it's easy to spot such three situations. They are correct code, yet experience shows that often such redundancies hide bugs. So I suggest to add to DMD warnings for such tree situations. See also bug 3878 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 07, 2011 [Issue 5540] Probable bug-hiding redundancies | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5540 --- Comment #1 from bearophile_hugs@eml.cc 2011-02-07 15:05:52 PST --- Another case, in good C++ code (probably caused by not complete copy & paste & modify): return Contains(Sphere(lss.mP0, lss.mRadius)) && Contains(Sphere(lss.mP0, lss.mRadius)); That is of this kind: x && x -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 07, 2011 [Issue 5540] Probable bug-hiding redundancies | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5540 --- Comment #2 from bearophile_hugs@eml.cc 2011-04-07 15:08:11 PDT --- Reference: http://www.viva64.com/en/a/0068/ -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 19, 2011 [Issue 5540] Probable bug-hiding redundancies | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5540 --- Comment #3 from bearophile_hugs@eml.cc 2011-06-19 16:38:35 PDT --- See a very nice example of bug of this kind, that's easy to find for a compiler or lint: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=139021 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 19, 2011 [Issue 5540] Probable bug-hiding redundancies | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5540 --- Comment #4 from bearophile_hugs@eml.cc 2011-06-19 16:44:30 PDT --- (In reply to comment #3) > See a very nice example of bug of this kind, that's easy to find for a compiler or lint: > > http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=139021 The bug in Andrej Mitrovic code was: if (mmioRead(hmmio, cast(LPSTR)&drum, DRUM.sizeof != DRUM.sizeof)) { mmioClose(hmmio, 0); return szErrorCannotRead; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 29, 2011 [Issue 5540] Probable bug-hiding redundancies | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5540 --- Comment #5 from bearophile_hugs@eml.cc 2011-06-29 13:24:48 PDT --- See also: http://www.viva64.com/en/b/0103/ http://www.viva64.com/en/d/0090/ -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 30, 2011 [Issue 5540] Probable bug-hiding redundancies | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5540 --- Comment #6 from bearophile_hugs@eml.cc 2011-06-29 16:56:41 PDT --- A class of bug-hiding redundancy: if (x == 10) foo1(); else if (x == 20) foo2(); else if (x == 10) // *** foo3(); Another class, two assignments to the same variable in a row: x = foo(); x = bar(); While this is OK: x = 1; x = x + 1; x = foo(x); Another class (the two branches are equal): if (x) foo(); else foo(); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation