Ping: Ping: [Patch][RFA] Warn if pointer is initialized to 'false'

Mark Mitchell mark@codesourcery.com
Sun Jan 31 21:53:00 GMT 2010


Simon Baldwin wrote:

>>> Confirmed C++ dejagnu testsuite parity with the unpatched gcc, and verified
>>> bootstrap of C/C++ on x86_64.
>>>
>>> Okay for trunk?  Would pedwarn be preferable to warning?

This patch is OK.

>>>        * call.c (conversion_null_warnings): Warn if 'false' is used in
>>>        pointer assignment or initialization.

No, I don't think so.  IIUC, false is a valid null pointer constant, so
there's no reason for a pedwarn; even when pedantic, this code is legal,
if odd.

The reason is that [pointer conversions] says that a null pointer
constant "is an integral constant expression with integer type that
evaluates to zero".  false is of type bool, which is an integral type,
and [fundamental types] defines "integer type" as a synonym for
"integral type" (with the consequence that the set of integer types is
not the union of the set of signed integer types and the set of unsigned
integer types).

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Gcc-patches mailing list