Creating pointer with all bits 0 (was: Referencing NULL pointers)

Tom Neff tneff at bfmny0.UUCP
Wed Sep 6 23:21:21 AEST 1989


I guess this 0 vs NULL thing will never get settled no matter how many
times Doug and Chris explain it.

So I'll carry the sandbucket for a turn. ;-)

 * Pointer and integer don't have to occupy the same storage or look
alike, and even where they do a NULL pointer doesn't have to contain all
zero bits.

 * Where a conforming program LOOKS like it's violating the above, by
casting 0 to a pointer type to create NULL, the compiler is welcome to
treat that instance of "0" *specially* so as to really create a NULL.
It does NOT mean that the pointer's storage is temporarily treated as
int storage and filled with the bit pattern an int 0 would get.

 * Other integer to pointer casts are not guaranteed to be portable.

 * Environments where constant pointers other than NULL are significant
do occur, but the situations where you use them are non-portable.  ANS
conforming compilers will presumably offer non portable extensions to
cover such things.  In widespread environments like UNIX where this is
an issue, it would be reasonable to defer to POSIX (e.g.) for guidance.
In DOS land and such, just use what the vendor supplies.
-- 
Annex Canada now!  We need the room,	\)	Tom Neff
    and who's going to stop us.		(\	tneff at bfmny0.UU.NET



More information about the Comp.lang.c mailing list