This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Request for warnings on implicit bool to int conversions


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
mathog@caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]