This is the mail archive of the egcs@egcs.cygnus.com mailing list for the EGCS project. See the EGCS home page for more information.
----- Original Message ----- From: Alexandre Oliva <oliva@dcc.unicamp.br> To: Gabriel Dos Reis <Gabriel.Dos-Reis@dptmaths.ens-cachan.fr> Cc: Doug Semler <doug@seaspace.com>; Chad Gatesman <chadg@redrose.net>; Jason Merrill <jason@cygnus.com>; <egcs@cygnus.com> Sent: Tuesday, March 02, 1999 11:37 PM Subject: Re: C++ definition of NULL >On Mar 3, 1999, Gabriel Dos Reis <Gabriel.Dos-Reis@dptmaths.ens-cachan.fr> wrote: > >> NULL is *not* a pointer. NULL is _convertible_ to pointer type. More >> explicitly, the C++ Standard says: > >> 4.10/1 >> --- >> A null pointer constant is na integral expression (5.19) rvalue of >> integer type that evaluates to zero. >> --- Damn, this one section is confusing....the way I've always read it is that NULL is a macro to a null pointer constant (18.1.4) (which may be 0 or 0L) A Null pointer constant is a constant rvalue integral *expression* which evaluates to 0. The Null pointer value (the value of the expression) can be converted to a cv-qualified type. The conversion from the expression is one step. So any constant integral rvalue of 0 can be a null pointer constant. So the way I read the standard, the type of a null pointer constant is a pointer type of pointer to destination's cv-qualified type. eg: int *a = NULL ; // NULL has type int * int a = NULL; // Error: cannot implicitly convert pointer type to int Right????? > >> So NULL is of integer type. Exactly wich one is implementation-defined. > >Actually, it needs not be an integer type; the definition > >enum __NULL_type { __null = 0 }; >#define NULL __null > >is a valid one, because integral expressions may involve enumerators.