`gcc -O2 -Wall' produces incorrect uninitialized variable warning

talon@clark.net talon@clark.net
Thu Jun 17 05:11:00 GMT 1999


/* Demonstrates bug in egcs-2.91.66 on FreeBSD 3.2.  To see the bug, 
   compile using: 
    
          gcc -c token.c -g -Wall -O2  
 
   The bug is the warning: 
 
     token.c:17: warning: `c' might be used uninitialized in this function 
 
   egcs-2.91.60 on Solaris 2.6 reports this message twice. 
*/ 
 
extern int getch(); 
extern int class(); 
 
int 
token() 
{ 
    int state = 1; 
 
    while (1) { 
        int c=0; 
        c = getch(); 
        switch (state) { 
        case 1: break; 
        case 4: break; 
        case 5: break; 
        case 6:  
            { 
                switch (class(c)) { 
                default: break; 
                } 
            } break; 
        case 7: break; 
        } 
    } 
} 
 


More information about the Gcc-bugs mailing list