I'm confused (Re: What C compilers have non-zero null pointers?)

rja rja at edison.cho.ge.com
Fri Jul 20 21:32:53 AEST 1990


Actually, I don't think I worded my posting clearly.

It is true without doubt that both K&R and ANS X3.159 C
both guarantee that comparing a pointer to "0" is the
same as comparing a pointer to "NULL."  

It is also something that is broken on several widely
used C compilers for the Intel segmented architecture.

At least one such compiler doesn't "#define NULL 0" or
even "#define NULL (void *)0" and will compare the offset
of the pointer to the offset of the NULL pointer address
rather than comparing the whole pointer to the whole NULL
pointer address.  In short, yes everyone agrees that such
compilers are broken but they are in common use and so
experience has taught some of us to always compare to NULL
rather than 0 because it is more portable to the several
broken compilers for the Intel architecture.  Ideally, one
can simply choose to avoid such compilers, but it isn't always
practical for non-technical reasons...



More information about the Comp.lang.c mailing list