Referencing NULL pointers

Lloyd Kremer kremer at cs.odu.edu
Tue Aug 29 05:09:10 AEST 1989



In article <10830 at smoke.BRL.MIL> gwyn at smoke.BRL.MIL (Doug Gwyn) writes:

>The compiler is entirely at liberty to IMMEDIATELY
>turn (whatever*)0 into an internal form such as (&__nullity), where
>__nullity is part of the C library.  If you were able to dereference
>such a "0-valued" pointer, in fact you'd access __nullity, not address 0.
>Therefore you'd better not have anything at address 0 that really needs
>to be accessed from C code.


This is true for integral constant 0, but could you not access memory
location 0 by writing:

	int data, p;

	p = 0;  /* integer variable that happens to be set to zero */
	data = *(int *)p;  /* no constant expression in this line */

I would think the "promotion to nil pointer" rule would not apply here.

-- 
					Lloyd Kremer
					...!uunet!xanth!kremer
					Have terminal...will hack!



More information about the Comp.lang.c mailing list