On Oct 18, 2013, at 8:25 AM, Sean McBride < email@hidden> wrote: Relatedly, I think a lack of warning on this is even worse:
BOOL x = ... if (x == YES) ...
Ouch, I’ve run into that before, especially with bit-tests like BOOL x = flags & (1<<kFlagBit); If kFlagBit isn’t zero, the example you gave doesn’t work right. (A related even worse case is where kFlagBit > 7, in which case x always ends up as 0 because the flag gets truncated out of the 8-bit BOOL value entirely, so even a correctly-written ‘if’ statement fails.)
My understanding is that with the ‘bool’ type my example would work correctly, because the assignment would do an implicit “!= 0” comparison, and maybe that was the justification for bool’s weird behavior. I’d much rather get a warning.
—Jens |