False warning in egcs 1.1.2

Giacomo Amabile Catenazzi cate@student.ethz.ch
Wed May 12 00:38:00 GMT 1999


When I compile the follow file, the compiles give me this warning:


~$ gcc -c -O3 -Wall egcstest.c
egcstest.c: In function `main':
egcstest.c:14: warning: `c' might be used uninitialized in this function
egcstest.c:14: warning: `i' might be used uninitialized in this function


Here the file giving problems. The variable 'c','i' are always
initialized before used. This warning apply only with -O3, and it
depends on code *after* the initialization.


-------------start-of---egcstest.c--------------
int opt;

int geteuid();
void exit(int);

void usage()
{
  exit(1);
}

int main(int argc, char *argv[])
{
  int c,i;

  if(geteuid()) {
    exit(1);
  }

  c = 0;
  while(++c < argc) {
    for(i = 1; argv[c][i]; i++) {
      switch(argv[c][i]) {
        case 'C':
          opt=1;
          break;
        case 'h':
          opt=2;
          break;
        case 'f':
          opt=3;
          break;
        case 'q':
          opt=4;
          break;
        case 's':
          opt=5;
          break;
        default:
          usage();
      }
    }
  }
  return 1;
}
----------end-of----egcstest.c------------- 


And here my system/compiler (I have compiled the egcs normally, without
experimental parameter, but I don't remember the ./configure params. )


~$ uname -a
Linux localhost.localdomain 2.2.7 #22 Mon May 10 19:37:43 CEST 1999 i686
unknown
~$ gcc -v
Reading specs from
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)



Giacomo Catenazzi


More information about the Gcc-bugs mailing list