What machines core dump on deref of NULL?

Larry Allen lwa at skeptic.osf.org
Fri Jun 29 23:32:28 AEST 1990


Sorry, John, I have to disagree.  On such a piece of hardware,
a NULL pointer simply can't be represented as an all zero
bit pattern.  The representation of the NULL pointer has
to guarantee that a NULL pointer will NEVER match a valid
address -- if it does, then a comparison against NULL is
not guaranteed to be unique.

You have to get out of the mindset of expecting that NULL
is equal to 0.  As Doug Gwyn has so eloquently pointed out
in the past, a NULL pointer is NOT a zero bit pattern, it's
a distinguished language construct that's represented by
the token "0" of type "pointer to ...".  The language
doesn't (and shouldn't) place any requirements on how
NULL is represented, save that it must not be the same
as any piece of valid storage that the program can
access.

So, you see, dereferencing a pointer whose bit representation
is 0 may well be a valid thing to do, but dereferencing a
NULL pointer is never valid.
					-Larry Allen
					 Open Software Foundation



More information about the Comp.unix.wizards mailing list