--- In [email protected], John Gaughan <j...@...> wrote: > Specifically, a pointer to memory location zero has special > meaning: this is defined to be a null pointer.
No, it is not. The integer constant 0 has special meaning in that it is a null pointer constant. If I do... int *i = 0; ...there is _nothing_ in the C language that requires the representation of the null pointer to point at memory address 0 (whatever that might mean!) ... > > It's up to the compiler, I think, to choose where a null > > pointer should point to. > > No, it is up to the standard. A null pointer MUST point to > memory address zero. No, it needn't. > From the C standard ISO/IEC 9899:1999(E), 6.3.2.3: "An > integer constant expression with the value 0, or such an > expression cast to type void *, is called a null pointer > constant." Tell me where the standard says that null pointer constants point to memory address zero. What you've quoted defines the grammar construct that shall be called a null pointer constant. The section goes on... "If a null pointer constant is converted to a pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function." There is no text that defines the conversion as producing a pointer to memory address zero (whatever that might mean.) -- Peter
