Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!mit-eddie!genrad!rep From: rep@genrad.UUCP Newsgroups: comp.lang.c Subject: Re: default initialization of static and extern Message-ID: <1297@genrad.UUCP> Date: Tue, 2-Jun-87 11:25:13 EDT Article-I.D.: genrad.1297 Posted: Tue Jun 2 11:25:13 1987 Date-Received: Thu, 4-Jun-87 06:11:47 EDT References: <158@delftcc.UUCP> <1070@viper.Lynx.MN.ORG> Reply-To: rep@genrad.UUCP (Pete Peterson) Organization: GenRad, Inc., Concord, Mass. Lines: 33 Keywords: C, NULL, portability In article <1070@viper.Lynx.MN.ORG> john@viper.UUCP (John Stanley) writes: >In article <158@delftcc.UUCP> henry@delftcc.UUCP (Henry Rabinowitz) writes: > >Are static pointers initialized to all bits zero or to the null value >(as in ANSI spec)? > If, you're refering to an initialized static, it's whatever you specify. If, on the other hand, you're refering to an UN-initialized static pointer, the answer is a resounding "Neither!".... An un- initialized variable is just that. It can initialy hold literaly -any- value that variable can possibly hold. You should never assume anything about any variable until you've set it. I have seen several claims to this effect in recent articles in this group, but K&R claims (in at least 3 places) that externs and statics are guaranteed to be initialized to zero in the absence of any explicit initializations. "The C Programming Language -- Reference Manual" by Ritchie as distributed with the BSD documentation makes the same statement. I don't see why it should be considered bad practice to rely on characteristics which are explicitly specified in the language definition. Are there really compilers which violate this specification? Another question about externs: Does anybody know why the DEC VAXC compiler (or linker) chose not to complain about externs which are never declared (without extern) anywhere. I can't see the benefit of this and it can lead to strange errors if you get the name wrong in some routine. pete peterson {decvax,linus,wjh12,mit-eddie,masscomp}!genrad!rep