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]

Re: Request for warnings on implicit bool to int conversions


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/>


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