[Issue 5540] New: Probable bug-hiding redundancies

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 7 12:35:51 PST 2011


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 at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at 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: -------


More information about the Digitalmars-d-bugs mailing list