www.digitalmars.com         C & C++   DMDScript  

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


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