Compiling this code with "g++-4.4 -O -Wall -g kk.cpp -fdiagnostics-show-option"... ============== struct S { int a; };
int main() { S s; int i; bool arr[1]; arr[s.a] =true; /*line 11: missed*/ arr[i] = true; /* if (s.a) return 1; */ return 0; } ============== produces kk.cpp:12: warning: i is used uninitialized in this function [-Wuninitialized] It realizes 1 bug, but not the one at line 11 (arr[s.a] =true) However, if we uncomment the "if (s.a)" it does detect this usage of uninitialized variable kk.cpp:8: warning: s.S::a is used uninitialized in this function [-Wuninitialized] thanks -- Summary: "uninitialized" warning missed when uninitialized class member used as array index Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gcc at dpinol dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40059