Caution for those considering MSC 5.0

Alan J Rosenthal flaps at csri.toronto.edu
Tue Feb 23 04:25:28 AEST 1988


In article <620 at viper.Lynx.MN.Org> john at viper.UUCP (John Stanley) writes:
>It's true on "many", but not all systems.  Rule of thumb is NEVER 
>assume any UN-initialized variable contains zero (or NULL)...  If you
>haven't explicitly put something into a variable, assume it's set to 
>a random value or the constant most likely to cause your procedure to 
>bomb....

ahem.  global and static variables are initialized to zero if they're
arithmetic, NULL if they're pointers, recursively through structs and
arrays but not unions (depending on who you ask); it's true that
automatic variables are not initialized.  (Unfortunately, vax bsd does
initialize them, analogous to making *(char *)0 == 0.)

There may be some implementations out there in which globals are not
properly initialized, but they're not full implementations of C, by
definition.

Your rule of thumb is valid for stylistic reasons, but stylistic
reasons only.

ajr
-- 
"noalias considered sailaon"



More information about the Comp.lang.c mailing list