NULL question not in FAQ

Christopher R Volpe volpe at camelback.crd.ge.com
Wed Apr 3 00:53:08 AEST 1991


In article <1103 at gtenmc.UUCP>, ravim at gtenmc.UUCP (Vox Populi) writes:
|>In article <1991Mar27.194101.1685 at grebyn.com> ckp at grebyn.com
(Checkpoint Technologies) writes:
|> >In article <1991Mar26.235643.4498 at ux1.cso.uiuc.edu>
phil at ux1.cso.uiuc.edu (Phil Howard KA9WGN) writes:
|> >>Given that the compiler is supposed to translate the constant "0" to the
|> >>appropriate value for a NULL pointer on the machine type, how does one
|> >>get a pointer value whose representation happens to be all zeroes, but
|> >>is a non-NULL pointer?
|> >
|> >void some_func(void) {
|> >	int **ip;
|> >
|> >	ip = (int **) calloc(sizeof(int *), 1);
|>
|>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.

No, that won't work. Statics are not initialized with zero bit patterns.
They are initialized as if they were assigned the constant 0. Thus, pointer
variables get the Null Pointer, and floats get the bit representation for
0.0. 
                       
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com



More information about the Comp.lang.c mailing list