Mail Archives: djgpp/1993/06/06/03:55:46
jih-shin ho: "static variable initialization" (Jun 5, 9:05):
> Hi:
> I find that gcc won't initialize static variable if you don't initialize
> it by hand.
>
> For example:
>
> static int i; <-- The value of i is undefined.
>
> static int i = 0; <-- You must use '= 0' to initialize i.
>
>
> This behavior violates ANSI definition.
Are You sure that ANSI C demands implicit initialisation to zero for any
variables? I don't remember it that way, and could not find any mention
about that in the book I had handy. Initialising to zero would
be a bad idea anyway, since half of the time zero would not be a good
initial value.
>Is this a bug ?
I believe it is not a bug. Explicit initialisation is a must.
> -- Jih-Shin Ho
>
Department of Computer Science Tapio Lehtonen FAX 708 4441
P.O. Box 26 (Teollisuuskatu 23) TELEX 122785 TSK SF
SF-00014 UNIVERSITY OF HELSINKI PHONE + 358 0 7084185 room D320
FINLAND Tapio DOT Lehtonen AT Helsinki DOT FI
- Raw text -