This is the mail archive of the
mailing list for the GCC project.
Re: Request for warnings on implicit bool to int conversions
Gabriel Dos Reis <firstname.lastname@example.org> 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
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 (email@example.com) <http://www.eyrie.org/~eagle/>