Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!ssc-vax!cxsea!blm From: blm@cxsea.UUCP (Brian Matthews) Newsgroups: comp.lang.c Subject: Re: calloc (actually NULL =?= 0) Message-ID: <2661@cxsea.UUCP> Date: 13 Apr 89 19:07:16 GMT References: <22842@shemp.CS.UCLA.EDU> <1428@auspex.auspex.com> <987@atanasoff.cs.iastate.edu> Reply-To: blm@cxsea.UUCP (Brian Matthews) Distribution: na Organization: Computer X Inc. Lines: 24 John Hascall (hascall@atanasoff.cs.iastate.edu) writes: |In article <1428@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes: |>>According to Harbison + Steele's book, calloc returns a region of |>>memory with all bits set to zero. They also point out that pointers |>>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": | | [talking about assigning ints to/from pointers | being "a bad thing"] ... | However, it is guaranteed that assignment of the | constant 0 to a pointer will produce a null pointer... But this doesn't guarantee that the resulting pointer consists of all zero bits. Arbitrary bit fiddling may occur during an assignment (consider assigning an int to a float, the bits can't be just copied), so just because you start with all 0 bits doesn't mean you end with all zero bits. -- Brian L. Matthews blm@cxsea.UUCP ...{mnetor,uw-beaver!ssc-vax}!cxsea!blm +1 206 251 6098 Computer X Inc. - a division of Motorola New Enterprises