1 Feb 2010 01:38
Re: Ping: Ping: [Patch][RFA] Warn if pointer is initialized to 'false'
Dave Korn <dave.korn.cygwin <at> googlemail.com>
2010-02-01 00:38:06 GMT
2010-02-01 00:38:06 GMT
On 31/01/2010 21:18, Mark Mitchell wrote: > 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). Yeah, but it's a bit of a nuisance when you accidentally "return false;" from something that returns a std::string (-> calls ctor string::string((const char *)0), which is illegal and generally segfaults), and you can't get a warning about it.(Continue reading)
RSS Feed