[Issue 12088] New: Bugs caused by using logical 'and' instead of bitwise 'and'

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 6 02:33:20 PST 2014


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


--- Comment #0 from bearophile_hugs at eml.cc 2014-02-06 02:33:12 PST ---
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: -------


More information about the Digitalmars-d-bugs mailing list