Uninitialized externals and statics

Wm E Davidsen Jr davidsen at crdos1.crd.ge.COM
Sat Aug 26 00:36:37 AEST 1989


In article <4700042 at m.cs.uiuc.edu>, kenny at m.cs.uiuc.edu writes:
> This is BROKEN.  How many times do those of us that understand this
> have to shout it?  When a pointer is compared with an integer, it is
> implicitly promoted to an integer.  Saying
	[ many things ]

  I think you may have missed the original posters point (he didn't shout
it). He was saying that on his machine a NULL pointer is not all bits zero.
Therefore if a C implementation set the pointer to "all bits zero" the
result would not be a NULL pointer, and would not compare equal to NULL.

  The ANSI standard calls for initialization to zero *cast to the
appropriate type* here, which would be another value. His compiler may be
non-conforming, but the point he was making has nothing to do with
promoting pointers to int (actually I think it's the other way round, since
an int may not be able to hold a pointer).

  The standard also allows NULL to be a pointer type ((void *) 0) which
would make it somewhat arcane to convert two pointer to integers to compare
them. 
-- 
bill davidsen	(davidsen at crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon



More information about the Comp.lang.c mailing list