the nil pointer is not zero
Doug Gwyn
gwyn at smoke.brl.mil
Sun Nov 18 08:01:39 AEST 1990
In article <164 at nazgul.UUCP> bright at nazgul.UUCP (Walter Bright) writes:
-Or a third method, commonly used on the PC: 0 is both the NULL pointer
-*and* is a valid address. If you wish to poke into the interrupt vector
-table, nothing stops you from doing this (and it works fine):
- long far *p = 0;
- *p = whatever;
-I'm also told that this solution is used on that Prime computer which seems
-to be the only one where NULL!=0. All that is necessary is to adjust malloc
-and the layout of the code and data so that it never sits on 0.
Certainly nothing stops you from dereferencing a null pointer (which
is what your example does), on systems where it happens to work by
accident.
-I think the ANSI C committee missed the boat on this. Thousands of hours
-of wasted time, confusion, and net debate would have been eliminated if
-NULL had been fixed at all bits 0.
I don't think so. What good would it do you to know how a null pointer
is represented? There is nothing useful you can do about that.
More information about the Comp.lang.c
mailing list