This is the mail archive of the
mailing list for the GCC project.
Re: Website patch: update projects to remove attribute nonnull
Kaveh R. Ghazi wrote:
I know in the past there's been some disagreement on whether NULL
should be defined with (void*) type or not, but that's not relevant
here and I don't want to start a flame war about it. I'm interested
in the practical application of this warning and whether people will
find it useful.
I'm not interested in a flame war either, but...
(void *)0 is not good enough for variadic arguments; it should
be (actual type *)0, as the pointer representation might be
different (it is required to work for pointers to character type,
Let's speak in terms in surveying our own code. On every single
platform on which gcc is supported, `NULL' works as a variadic
function terminator even if the function expects a pointer zero. I
know this because we terminate uses of libiberty's concat with NULL
everywhere in gcc. This works because every implementation takes care
to ensure the width of the NULL integer zero is the same width as a
pointer. E.g. NULL is often "0L" on LP64 systems.
concat() is the (char *) case, which is required to be compatible with
plain (void *)0.
I don't think gcc is unique in its usage of NULL in this fashion.
Part of maiking warnings useful is to avoid spurious warnings. IMHO,
warnings about NULL in this context are spurious, it would preclude
turning on this warning in -Wall for sure. I agree we should warn if
At least turn it on in Standard C mode?
someone uses a naked 0 and sizeof(int) != sizeof(void*), but that's an
I would say that it's still a bug if sizeof(int) == sizeof(void *), it's
just not a bug that manifests itself -- the worst kind.
I think it's fine GCC accepts all kinds of sloppy code, but it should
at least warn about it with -Wall.