Uninitialized externals and statics.

Tim Cook timcc at csv.viccol.edu.au
Tue Aug 22 09:21:07 AEST 1989


In article <1989Aug19.053711.7462 at twwells.com>, bill at twwells.com (T. William Wells) writes:
> In article <478.nlhp3 at oracle.nl> bengsig at oracle.nl (Bjorn Engsig) writes:
> : The default initialization of statics and externals without explicit inital
> : values also has the advantage (at least on some systems) that the load
> : module will be smaller.  If you explicitly initialize to zero, all those
> : zeroes will be stored in the file.
> 
> At one point, we got toasted by some of our customers because our
> executables were excessively large. It seems that one of our
> programmers did things like:
> 
> int     Array[1000] = {0};
> 
> This sort of thing made the difference between a product that could
> be shipped on one floppy and one that required two.
> 
> Guk.

Let's not misappropriate blame here.  It seems to me that your compiler
should take the blame in this scenario.  Your programmer is simply making
sure of what will be in "Array" when the program starts (sounds like a
worthwhile programming practice).

It's not his fault if the compiler can't sense that he has initialized it
to the default.  Seems like a simple optimization to me.

(Of course, most C compilers produce assembler, so they could have a go at
passing the buck on this one).



More information about the Comp.lang.c mailing list