With: * gcc-4.8 (Debian 4.8.2-5) 4.8.2 * gcc (Debian 20131021-1) 4.9.0 20131021 (experimental) [trunk revision 203899] xvii:~> cat tst1.c int foo (int x) { int y; if (x == 0) y = 1; return y; } "gcc-snapshot -O2 -Wuninitialized -c tst1.c" doesn't emit any warning. If I change the code to: xvii:~> cat tst2.c int foo (int x) { int y; if (x == 0) y = 1; else if (x == 1) y = 2; return y; } I get the following warning as expected: tst2.c:8:3: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized] return y; ^
CCP assumes y == 1 in the first testcase, this is PR18501 In the second testcase, y may be either 1 or 2, so CCP does not kick-in, and nothing removes the undefined operand of the PHI node: # RANGE [1, 2] NONZERO 0x00000000000000003 # y_1 = PHI <[test2.c : 5:7] 1(6), y_3(D)(4), [test2.c : 7:7] 2(7)> [test2.c : 8:3] # VUSE <.MEM_4(D)> return y_1; so we can warn. *** This bug has been marked as a duplicate of bug 18501 ***