"John David Anglin" <[EMAIL PROTECTED]> writes:

| > > 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;

Where does the standard says that reading the value of an
unitialized object of character type is undefined behaviour?

My reading has always been that character types are exempted from that
black hole stuff.

-- Gaby

Reply via email to