NULL question not in FAQ

Wayne Throop throopw at sheol.UUCP
Mon Apr 8 10:25:46 AEST 1991


> ravim at gtenmc.UUCP (Vox Populi)
> The same result (getting a pointer value to be all null bytes) can also be
> achieved by declaring the pointer variable to be either static or/and global,
> since static/global variables are automatically initialized to zeroes.

As the cliche now goes.... 
"Bzzzzzzzzt!  Wrong!  But thank you for playing our game!"

The problem here is that pointers and floating point values are a
special case, and initializing them to zero doesn't guarantee a
byte-wise or bit-wise zero value.  Further, uninitialized static or
global variables of these types are mandated by X3J11 (the ANSI C
standard) to act like they'd been subjected to initializers to zero,
not to "bzero" or "all bits (or bytes) zeroed". 

Um... that is...
unless the phrase "can be achieved" meant "on some particular machines",
rather than "portably".
--
Wayne Throop  ...!mcnc!dg-rtp!sheol!throopw



More information about the Comp.lang.c mailing list