Path: utzoo!dciem!nrcaer!sce!cognos!jimp From: jimp@cognos.uucp (Jim Patterson) Newsgroups: comp.lang.c Subject: Re: malloced structure initilization Message-ID: <5280@aldebaran.UUCP> Date: 14 Feb 89 19:31:56 GMT Article-I.D.: aldebara.5280 References: <202@sabin.UUCP> <8894@alice.UUCP> <1874@dataio.Data-IO.COM> Reply-To: jimp@cognos.UUCP (Jim Patterson) Organization: Cognos Inc., Ottawa, Canada Lines: 27 In article <1874@dataio.Data-IO.COM> bright@dataio.Data-IO.COM (Walter Bright) writes: >In article <8894@alice.UUCP< ark@alice.UUCP (Andrew Koenig) writes: >< static struct foo init_foo; >Yah, and init_foo is guaranteed to be initialized to a 0 bit pattern, Not so, according to the pANS C. See section 3.5.7: "If an object that has static storage duration is not initialized explicitly, it is initialized implicitly as if every member that has arithmetic type were assigned 0 and every member that has pointer type were assigned the null pointer constant" As far as I know, on every known architecture supporting C the effect is exactly the same anyways. (Somebody, please correct me IF YOU KNOW OF A COUNTER EXAMPLE. I've seen too many people say that it's not guaranteed by pANS C, which I know, but I have not yet seen the name of a single machine or system with a C compiler for which it isn't true). -- Jim Patterson Cognos Incorporated UUCP:decvax!utzoo!dciem!nrcaer!cognos!jimp P.O. BOX 9707 PHONE:(613)738-1440 3755 Riverside Drive Ottawa, Ont K1G 3Z4