What machines core dump on deref of NULL?

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Jul 8 16:07:02 AEST 1990


In article <9361 at rice-chex.ai.mit.edu> bson at rice-chex.ai.mit.edu (Jan Brittenson) writes:
>>Distinguishable in this sense just means you can use tests like
>>p=0;
>>if (p == &someobject)
>>	code();
>>else
>>	othercode()
>>which will always fail

Correct, and that is the primary reason why the C standard requires
that a null pointer not compare equal to a pointer to any object.

>   Not if someobject resides at address 0, in which case p does point
>to an object.

A conforming C implementation cannot allocate someobject at such as
address that a pointer to it is indistinguishable from a null pointer.

A (not strictly conforming) application may, through appropriate
implementation-specific manipulations, produce such an object pointer,
but what it points to will not qualify as an "object" in the sense in
which the term is used in the C standard.



More information about the Comp.unix.wizards mailing list