gcc -O2 -Wuninitialized bug with &var under 2.95.2

Gray Watson gray@256.com
Fri Apr 21 14:59:00 GMT 2000


System and gcc version:

    Linux squirrel 2.2.14 #6 Mon Jan 31 14:32:43 EST 2000 i686 unknown
    gcc version 2.95.2 19991024 (release)

The following program will not generate an error:

    #include <stdio.h>
    void foo(int *i_p) {}
    int main()
    {
      int i;
      if (i) (void)printf("%d?\n", i);
      /* ^^^ use of unitialized variable */
      foo(&i);
      /*  ^^ the reason why it isn't reported */
      return 0;
    }

If you remove the foo(&i) or substitute a i = 1 then it will see that
the if (i) line accesses a unitialized variable.

I'd call it a bug although it might be a by-product of block processing
in function.c.

Comments?
---
gray.reply@256.com


More information about the Gcc-bugs mailing list