This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: No pointer conversion warning for "bool" in C/C++
- From: Ian Lance Taylor <iant at google dot com>
- To: Jon Grant <jg at jguk dot org>
- Cc: gcc at gcc dot gnu dot org
- Date: Sun, 25 Sep 2011 21:29:00 -0700
- Subject: Re: No pointer conversion warning for "bool" in C/C++
- References: <4E7FA590.8020501@jguk.org>
Jon Grant <jg@jguk.org> writes:
> Currently gcc, and g++ don't give a warning when a pointer was
> converted to a bool, in the same way it is for other types.
There is a lot of code which uses
if (p)
where p is a pointer to test whether p is not NULL. I don't think we
could reasonably have gcc warn about such a case.
We might be able to separate out conversion to bool on assignment from
conversion to bool in a test, though.
Ian