The C99 bool data type, and the similar type in C++, currently (v
4.5.2) do not generate
warnings for any of these sorts of operations:
bool b;
b = 3;
b++;
b += 2;
if(b == 3)
etc.
This can lead to a lot of hidden mischief because a variable declared
far away may look like
an integer, but it acts like a bool. It would be nice if there was a
-Wimplicit_bool
that was enabled in -Wall which complained about these sorts of
operations. In particular
it would warn any time a bool was implicitly promoted to an int.
This issued was recently discussed in newsgroup comp.lang.c under the
subject:
c99 and the lack of warnings when int operations are applied to a bool
Thank you,
David Mathog
mat...@caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech