Referencing NULL pointers
Richard Tobin
richard at aiai.ed.ac.uk
Wed Aug 30 02:20:23 AEST 1989
In article <9838 at xanth.cs.odu.edu> kremer at cs.odu.edu (Lloyd Kremer) writes:
>This is true for integral constant 0, but could you not access memory
>location 0 by writing:
> p = 0; /* integer variable that happens to be set to zero */
> data = *(int *)p; /* no constant expression in this line */
Probably, but there's nothing to stop a cast doing something strange.
This may work better (but of course is still completely unreliable):
union {int i; int *p} x;
x.i = 0;
data = *x.p;
-- Richard
--
Richard Tobin, JANET: R.Tobin at uk.ac.ed
AI Applications Institute, ARPA: R.Tobin%uk.ac.ed at nsfnet-relay.ac.uk
Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin
More information about the Comp.lang.c
mailing list