March 10, 2006
"Sean Kelly" <sean@f4.ca> wrote in message news:dur6p8$2ila$1@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.


March 10, 2006
Walter Bright wrote:
> "Sean Kelly" <sean@f4.ca> wrote in message news:dur6p8$2ila$1@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. 

Oh I see.  Makes a lot more sense now :-)


Sean
1 2
Next ›   Last »