April 04, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5814

           Summary: A bug with bitwise and among booleans
           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-04-04 15:45:00 PDT ---
According to this article this D code shows a common bug: http://www.viva64.com/en/a/0072/


void main() {
    enum uint BAR = 0b011;
    auto foo = 10;
    auto x = !foo & BAR;
}


!foo is a boolean, and usually you don't want to perform a bitwise operation on a boolean value. So the probable bug in that code is the usage of & instead of &&.

(This C++ bug is caused by two design decisions: to use the two very similar symbols && and & to denote two very different operations, and to allow mixing boolean and integer/bitwise operations).

If this class of bugs is seen as frequent enough, then a possible design solution to avoid them in D is for D language to not allow the bitwise operators as & and | to have a boolean operand.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5814


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #1 from bearophile_hugs@eml.cc 2011-07-09 11:08:24 PDT ---
*** This issue has been marked as a duplicate of issue 5409 ***

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