Referencing NULL pointers

carroll at s.cs.uiuc.edu carroll at s.cs.uiuc.edu
Tue Jul 18 01:17:00 AEST 1989


/* Written  3:44 pm  Jul 16, 1989 by jbm at eos.UUCP in s.cs.uiuc.edu:comp.unix.wizards */

It has been pointed out that there should be no assumptions
about what addresses are valid; is there any way to get
a guaranteed INVALID address?
/* End of text from s.cs.uiuc.edu:comp.unix.wizards */
What do you mean by "INVALID"? That it will cause a core dump when
written to, just dereferenced, or is never a valid pointer value? For the
first two, no, there isn't one. For the last, you should be able to use 0
(or better, NULL from stdio.h). According to K&R(1), the value 0 for a pointer
is guaranteed not to point to a valid object. I find it difficult to believe
that ANSI-C changed that.

Alan M. Carroll                "Oh goody, the Illudium Q-36 Explosive
carroll at s.cs.uiuc.edu           Space Modulator!"
CS Grad / U of Ill @ Urbana    ...{ucbvax,pur-ee,convex}!s.cs.uiuc.edu!carroll



More information about the Comp.unix.wizards mailing list