What C compilers have non-zero null pointers?
Isaac Rabinovitch
ergo at netcom.UUCP
Wed Jul 18 05:38:10 AEST 1990
In <9007161750.AA00664 at edison.CHO.GE.COM> rja at edison.cho.ge.com (rja) writes:
>I used to use a compiler for MSDOS and the 80x86 cpus
>whose NULL pointer was F000:0000 hex when examined via
>a debugger. It of course did compile fine as long as one
>used sense and compared pointers to NULL rather than
>a constant of zero...
True. But what the "NULL should always be 0" diehards want is not to
write (for example)
for (ptr = fist; ptr != 0; ptr = ptr->next)
in which 0 should probably be #DEFINED anyway, but rather
for (ptr = first; ptr ; ptr = ptr->next)
which produces tighter code and (most important of all) looks
spiffier. It has the elegance of expression old C hands crave.
>Compilers where NULL isn't represented as all zero bits
>just aren't that uncommon.
My '78 K&R says that assigning 0 to a pointer is (or was) guarranteed
to produce a NULL, even on compilers that didn't like other
integer-to-pointer assignments. But, interestingly, they did *not*
guarantee, even then, the reverse!
--
ergo at netcom.uucp Isaac Rabinovitch
atina!pyramid!apple!netcom!ergo Silicon Valley, CA
uunet!mimsy!ames!claris!netcom!ergo
"I hate quotations. Tell me what you know!"
-- Ralph Waldo Emerson
More information about the Comp.lang.c
mailing list