Comment #0 by bearophile_hugs — 2011-04-04T15:45:00Z
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.
Comment #1 by bearophile_hugs — 2011-07-09T11:08:24Z
*** This issue has been marked as a duplicate of issue 5409 ***