dmd warning request: warn for bitwise OR in conditional
Ali Çehreli
acehreli at yahoo.com
Thu Jan 21 22:34:57 PST 2010
We've been bitten by the following bug recently in C code:
uint flag = 0x1;
uint flags;
if (flags | flag) {
dout.writefln("oops");
}
The programmer intended &.
It is (almost?) always an error to use | in a conditional. At least the
conditional in the above code is always true; so dmd could generate a
warning. (Yes, I used -w.)
Ali
More information about the Digitalmars-d
mailing list