[Bug 24] Arithmetic operators are allowed on boolean expressions
Walter Bright
newshound at digitalmars.com
Thu Mar 9 22:42:33 PST 2006
"Sean Kelly" <sean at f4.ca> wrote in message
news:dur6p8$2ila$1 at digitaldaemon.com...
>> bool x5; x5 += true; // fails because x5+true is int, and int cannot
>> be
>> implicitly converted to bool unless it is 0 or 1
>
> bool defaults to false/0, so x5 + true should equal 1, which should not
> fail.
That would be true if x5 is a const, but it isn't, so it doesn't get
constant folded. The same applies to the other examples.
More information about the Digitalmars-d-bugs
mailing list