www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12088] New: Bugs caused by using logical 'and' instead of bitwise 'and'

https://d.puremagic.com/issues/show_bug.cgi?id=12088

           Summary: Bugs caused by using logical 'and' instead of bitwise
                    'and'
           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



This is not an enhancement request, it shows a language small design problem.

D gives no warnings nor errors on this code:


void main() {
    uint x;
    ubyte y = (x >> 16) && 0xFF;
}


Here to extract a ubyte the programmer has used a logical 'and' instead of a
bitwise 'and' by mistake. And it's not an uncommon mistake.

Ideas to face this kind of bugs are welcome.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 06 2014