Using GCC 4.4.1 and the command on the following test gcc -O2 -Wall -Wextra
#include <stdio.h> int foo (int b) { int a[10], c, i; for (i = 0; i < b; i++) { a[i] = b; c = b; } if (a[2] == 5 && c == 5) { printf("hello world\n"); } return 0; } testWarn.c: In function 'foo': testWarn.c:5: warning: 'c' may be used uninitialized in this function However, a warning for a[2] being possibly uninitialized is missing. If I understand right, this should be handled by late warning pass which just after DCE. Looking at post DCE dump foo (int b) { unsigned int D.1282; int i; int c; int a[10]; _Bool D.1243; _Bool D.1242; _Bool D.1241; int D.1240; <bb 2>: if (b_5(D) > 0) goto <bb 3>; else goto <bb 4>; <bb 3>: # i_21 = PHI <0(2), i_8(3)> D.1282_25 = (unsigned int) i_21; MEM[base: &a, index: D.1282_25, step: 4] = b_5(D); i_8 = i_21 + 1; if (i_8 != b_5(D)) goto <bb 3>; else goto <bb 4>; <bb 4>: # c_17 = PHI <b_5(D)(3), c_4(D)(2)> D.1240_9 = a[2]; D.1241_10 = D.1240_9 == 5; D.1242_11 = c_17 == 5; D.1243_12 = D.1242_11 & D.1241_10; if (D.1243_12 != 0) goto <bb 5>; else goto <bb 6>; <bb 5>: __builtin_puts (&"hello world"[0]); <bb 6>: return 0; } there is a path to bb 4, which does not initialize a. Why do we not generate a warning? Is it due a missing PHI for a? -- Summary: Missed "may be uninitialized warning" on array reference Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: minor Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rahul at icerasemi dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41834