This is the mail archive of the gcc-patches@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: [C++ patch] accept __null as sentinel


Michael Matz wrote:
Hi,

On Fri, 29 Apr 2005, Mark Mitchell wrote:


Maybe.  But note that the case of a literal 0 will still be warned (as
also for 0L), no matter what.  It's only __null, a GCC specific thing,
which I don't want to warn about, in a warning only implemented by
GCC.  We _know_ using __null will work.

But the user (probably) didn't write "__null" -- they wrote "NULL". So, what we really know is that using GCC's <stddef.h> will work. But
if you're trying to write code portable to non-GCC compilers, then the
warning still has value for you.


That's why a suggested to put it under -pedantic.

The documentation for -pedantic says:


"Issue all the warnings demanded by strict ISO C and ISO C++; reject all programs that use forbidden extensions, and some other programs that do not follow ISO C and ISO C++."

Failing to pass a proper NULL pointer to a function with __attribute__((sentinel) is not a failure to conform to ISO C++. Whereas -Wall is documented as:

"This enables all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify to prevent the warning), even in conjunction with macros."

So, -Wall would be a better place, or -Wformat=2, as Joseph suggests, if we think the warning is too annoying by default.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


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