Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!twwells!bill From: bill@twwells.com (T. William Wells) Newsgroups: comp.lang.c Subject: Re: Representation of NULL and 0.0 (was Re: Zero Length Arrays ...) Message-ID: <1989Dec17.175835.21745@twwells.com> Date: 17 Dec 89 17:58:35 GMT References: <2298@jato.Jpl.Nasa.Gov> <11715@smoke.BRL.MIL> <480@codonics.COM> <1989Dec2.210042.12668@twwells.com> <8129@cg-atla.UUCP> <1989 <545@mwtech.UUCP> Organization: None, Ft. Lauderdale, FL Lines: 41 In article <545@mwtech.UUCP> martin@mwtech.UUCP (Martin Weitzel) writes: : >Warning: null pointers and floating point zeros are *not* : >necessarily represented by bit patterns of all zero bits. : : Sorry, my copy of the draft is not the most recent (we Europeans : seem to have no easy way, to get an up-to-date *A*NSI-Standard :-/), Actually, most everyone gets it the same way: by calling someone (is Global Engineering the only one?) and ordering a copy. It has been just as difficult for us U.S.*A*mericans to get an up to date standard. : If the type of "a" would have been int or long, one could ommit : the initialization loop and replace malloc with calloc, which may : have a faster way to zero the allocated space. (Am I right so far?) Yes. Also for short or char. : Wouldn't it have been wise to add another 'calloc' for floating : types and NULL pointers, as the initializing feature of calloc : is weak in this respect? (As an aside, the pure existance of : such a function would have warned all programmers, who are still : in believe, they allways receive NULL-pointers or 0.0 from calloc). Maybe. I'm of the opinion that calloc should simply go away. I never use it. : Now, how is the situation with statically allocated data (esp. : not fully initialized arrays). The compiler 'knows' the exact : data type in this situation (other than calloc in the above example) : and could use 'the right' representation. What are the guarantees : of the standard: zero bits or NULL resp. 0.0? NULL or 0.0. The one case I didn't see covered was the initial value of a union. It appears that the union is initialized as if its first element were initialized, but I didn't see it say this explicitly. --- Bill { uunet | novavax | ankh | sunvice } !twwells!bill bill@twwells.com