Uninitialized externals and statics.

T. William Wells bill at twwells.com
Wed Aug 23 00:51:55 AEST 1989


In article <1423 at csv.viccol.edu.au> timcc at csv.viccol.edu.au (Tim Cook) writes:
: 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.

#1: Essentially *every* compiler does this particular bogosity. That
    means that a competent programmer had better be aware of it and
    deal with it. (Let me put it another way: I don't know of any
    that don't.)

#2: We shipped *source code* to our customers. They were complaining
    because *their* compilers made the executables too large. (So
    also did, and do, ours.)

#3: No, we could *not* tell them to use another compiler. Firstly,
    they wouldn't. Second, it almost always wouldn't make a
    difference (see #1). And third, in some cases, there *weren't*
    alternate compilers.

    (Which reminds me: someone asserted that there are more 80x86's
    running C programs than any other microprocessor. I doubt it. I
    suspect that it is something like an 8051, Z80, or other equally
    puerile processor. Do you know how many typewriters, toaster
    ovens, and computer toys are out there today? Programmed in C?
    For a guess, someone might want to look up Franklin Computer's
    sales of their hand-held spellers: these are sold in the
    millions. Most has something less than an 8086 in them. And they
    are all programmed mostly in C.

    Why am I reminded? Guess which processors have the greatest lack
    of even semi-functional C compilers? And which require the
    greatest competence in programmers to make things come out
    reasonably?)

Welcome to the real world.

---
Bill                    { uunet | novavax | ankh | sunvice } !twwells!bill
bill at twwells.com



More information about the Comp.lang.c mailing list