Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!crdgw1!crdos1!davidsen From: davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) Newsgroups: comp.lang.c Subject: Re: Uninitialized externals and statics Message-ID: <162@crdos1.crd.ge.COM> Date: 25 Aug 89 14:36:37 GMT References: <2128@infmx.UUCP> <4700042@m.cs.uiuc.edu> Organization: GE Corp R&D Center Lines: 25 In article <4700042@m.cs.uiuc.edu>, kenny@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@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