> > This seems pretty clear. C99 requires that storage be allocated > > > >for uninitialized objects, that an indeterminate value be stored > >in the object when the declarator for the object is reached in the > >block, that the last-stored value be retained for the duration of > >the block. > > > > > I think that is an incorrect interpretation. Remember the standard is > always "as-if" when it gives an implementation approach. Please > show a correct C program that can tell that gcc is not following > the above scheme.
#include <stdio.h> unsigned char T (unsigned char x) { static int first = 1; static unsigned char firstx; if (first) { first = 0; firstx = x; return ~x; } if (x == firstx) printf ("Behavior is pre GCC 4.0\n"); else printf ("Behavior is GCC 4.0 and later\n"); return 0; } *** cut *** extern int T (unsigned char); int foo (void) { int result; unsigned char x; result = T (x); T (x); return result; } int main () { return foo (); } Compile as follows: gcc-3.4 -O2 -c T.c gcc-3.4 -o und -O2 und.c T.o ./und Behavior is pre GCC 4.0 gcc-4.0 -o und -O2 und.c T.o Behavior is GCC 4.0 and later That's what I see on hppa-unknown-linux-gnu. The 4.0 behavior is caused by GCC using result for the second call to T, whereas 3.3 and 3.4 use the same undefined value for both calls to T. Dave -- J. David Anglin [EMAIL PROTECTED] National Research Council of Canada (613) 990-0752 (FAX: 952-6602)