Request for warnings on implicit bool to int conversions
Russ Allbery
rra@stanford.edu
Wed Mar 28 02:40:00 GMT 2012
Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
> I can easily see why an implicit conversion from int to bool might cause
> a problem, even if that is what the language standard mandates -- just
> look at the most common misuses of strcmp. But, that is not what the
> proposer requested, which got me scratching my head.
Yeah. But I suspect it was a mistaken statement. The subject line from
the referenced comp.lang.c thread was:
c99 and the lack of warnings when int operations are applied to a bool
which I think is best caught by the conversion *to* bool when the result
is stored, rather than the conversion *from* bool to perform the
operation.
I could see the other direction being marginally helpful in catching
people adding bools together, which may not make a lot of sense, but it
doesn't seem as likely to cause bugs.
--
Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>
More information about the Gcc
mailing list