Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!ginosko!husc6!paperboy!osf!dbrooks From: dbrooks@osf.osf.org (David Brooks) Newsgroups: comp.lang.c Subject: Re: Uninitialized externals and statics Message-ID: <609@paperboy.OSF.ORG> Date: 26 Aug 89 04:38:37 GMT References: <2128@infmx.UUCP> <4700042@m.cs.uiuc.edu> <1989Aug25.185428.3511@utzoo.uucp> Sender: news@OSF.ORG Reply-To: dbrooks@osf.org (David Brooks) Organization: Open Software Foundation Lines: 28 In article <1989Aug25.185428.3511@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: [...] > There is one, repeat one, special >case: an integer constant expression of value zero -- repeat, an >integer CONSTANT expression of value ZERO -- gets turned into a NULL >pointer of the appropriate type when compared to a pointer. Note that >it is the integer, not the pointer, that is converted. Note that no >such conversion is done on integer variables, integer constant expressions >with non-zero values, or general integer expressions. I was about to make the same point myself. This can be determined by careful reading of K&R II: try section A6.6, page 198. The constant 0 may be converted by a cast, by assignment, or by comparison, to a pointer. This legitimizes "if (p == 0)". Requiring an actual conversion step removes any implicatino that the pointer is zero-valued. Anyway, I had a question: what is this assumption about "all bits zero" for the common case of initializing ints? I wonder if there's any machine out there that represents int 0 with some other bit pattern... Those of us old enough to remember when ones-complement seemed like a good idea can begin to break into a sweat at this point :-) -- David Brooks dbrooks@osf.org Open Software Foundation uunet!osf.org!dbrooks 11 Cambridge Center Personal views, not necessarily those Cambridge, MA 02142, USA of OSF, its sponsors or members.