Newsgroups: comp.lang.c Path: utzoo!utgpu!jarvis.csri.toronto.edu!csri.toronto.edu!flaps From: flaps@csri.toronto.edu (Alan J Rosenthal) Subject: Re: Caution for those considering MSC 5.0 Message-ID: <1988Feb22.132528.11732@jarvis.csri.toronto.edu> Organization: University of Toronto References: <11754@brl-adm.ARPA> <620@viper.Lynx.MN.Org> Date: Mon, 22-Feb-88 13:25:28 EST In article <620@viper.Lynx.MN.Org> john@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"