[comp.lang.c] Truly bizarre behavior

drw@cullvax.UUCP (Dale Worley) (06/04/87)

I've seen a couple of articles that run about as follows:

john@viper.Lynx.MN.ORG (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.

However, my memory says that statics without explicit initialization
are initialized to 0 or NULL.  So I looked up the references:

	Static and external variables which are not initialized are
	guaranteed to start off as 0 ... .  (K&R page 198)

	Any static variable that does not have an explicit initializer
	will be initialized to zero.  (H&S page 72)

	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 a null pointer constant.
	(ANSI 3.5.6, page 61)

It seems to be pretty well agreed upon that "uninitialized" statics
are required to be 0 or NULL.  Maybe it would have been better if this
rule wasn't installed, but it's too late now.  But how do people get
the idea that C *doesn't* require the implementation to initialize
statics?

Dale
-- 
Dale Worley		Cullinet Software
UUCP: ...!seismo!harvard!mit-eddie!cullvax!drw
ARPA: cullvax!drw@eddie.mit.edu
Un*x (a generic name for a class of OS's) != Unix (AT&T's brand of such)