Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.lang.c Subject: Re: calloc (actually NULL =?= 0) Message-ID: <1433@auspex.auspex.com> Date: 14 Apr 89 18:16:23 GMT References: <22842@shemp.CS.UCLA.EDU> <1428@auspex.auspex.com> <987@atanasoff.cs.iastate.edu> Reply-To: guy@auspex.auspex.com (Guy Harris) Distribution: na Organization: Auspex Systems, Santa Clara Lines: 31 >>>I always thought a pointer consisting of zero bits is NULL. > >>Nope. No such guarantee was ever made by any C language spec. > > What about the following taken from K&R, Appendix A, section 7.14, > "Assignment operator": > > However, it is guaranteed that assignment of the > constant 0 to a pointer will produce a null pointer... Sigh, time for yet another explanation of what this really means.... This is in no way, shape, or form a guarantee that a null pointer consists solely of zero bits! All it guarantees is that assignments such as register char *p; p = 0; cause a null pointer value to be assigned to "p". If the representation of a null pointer on some hypothetical implementation is 0xFF000000, the code generated for the aforementioned statement might be something such as: mov #FF000000,%r3 if, say, "p" were assigned to register "r3". The compiler knows, in this context, that the "0" must be converted to a null pointer of type "char *", and does precisely that conversion.