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++] warn if NULL is passed through varargs


> 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.


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