This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [c++] warn if NULL is passed through varargs
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: Paul Koning <pkoning at equallogic dot com>, drow at mvista dot com, fjh at cs dot mu dot OZ dot AU, pinskia at physics dot uc dot edu, aoliva at redhat dot com, gcc-patches at gcc dot gnu dot org, Richard dot Earnshaw at arm dot com
- Date: Wed, 09 Oct 2002 15:34:49 +0100
- Subject: Re: [c++] warn if NULL is passed through varargs
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> Paul Koning <pkoning@equallogic.com> writes:
>
> [...]
>
> | Daniel> - First of all, there's no real way to figure it out. C++
> | Daniel> has __null (spelling?), but C just has a NULL somewhere.
> | Daniel> Defined usually as (void*) 0, at least for GCC.
> |
> | I had the same reaction. In C, NULL is just a #define, whose
> | definition varies.
In fact the C standard is quite clear that '(void*) 0' is *NOT* a valid
definition for NULL. (void*)0 cannot be legally used where a pointer to a
function is involved and it must be possible to assign NULL to such a
pointer.
My understanding is that there are, in practise, only about three
reasonable definitions of NULL, being 0, 0L or __builtin_null (where the
latter is handled internally by the compiler).
R.