Quote:Original post by Hnefi
NULL is defined in the C++ standard, along with special behavior for pointers that are NULL (it is always safe to delete a NULL pointer).
Nope [smile] the C++ standard defines special behavior for pointers that are null. NULL itself is mentioned as being an implementation-defined macro for a C++ null pointer constant in 18.1 §4, and a null pointer constant itself is defined by 4.10 §1 as being any constant integer expression which evaluates to zero.
Quote:Original post by rip-off
0, as well as being an integer constant, is also the null pointer constant. NULL is #define NULL 0.
The thing that is undefined is the bit pattern that the pointer constant 0 has.
Nope [smile] first, 0 is not "the null pointer constant", its just "a null pointer constant". (1-1) or (1*0) or (1>>1) are also null pointer constants by virtue of 4.10 §1. Then, NULL is an implementation-defined macro, which may thus be defined to something else (such as 0L instead of 0). Finally, the pointer constant 0 has no bit pattern: it's just a token in your source code. The
null pointer value, unlike a null pointer constant, is unique, exists at runtime, and has an unspecified binary representation.