Compiling the following code with -O2 -W -Wall, gcc-3.2 gives a warning: p.c: In function `bar': p.c:4: warning: `res' might be used uninitialized in this function No open branch does, anymore. p.c: int bar(int foo) { int res; if (foo) { } else { res = 0; } return res; } int main() { return bar(1); } This PR seems similar to PR22456, but this code isn't a loop. If it really is the same, I guess WONTFIX.
It is. *** This bug has been marked as a duplicate of 22456 ***
No, it is not. There is no loop here, this is CCP assuming that res is 0 always.
... so this is actually a duplicate of bug 18501. *** This bug has been marked as a duplicate of 18501 ***
(In reply to comment #3) > ... so this is actually a duplicate of bug 18501. > > *** This bug has been marked as a duplicate of 18501 *** The loopness distinction for duplicate-marker seems bogus: PR22456 has a while-loop. The test-case for PR18501 has a for-loop. This one doesn't have a loop. Just saying, again.
The difference is what GCC does/does not to detect/hide the warning. Here, and in 18051, the CCP pass assumes a value for the uninitialized variable, and hence, the uninit use disappears, so no warning can occur. In PR 22456, CCP does not act but there is no warning because the loop is empty and later optimizations remove it completely. See the difference now?
(In reply to comment #5) > See the difference now? Thanks, that helped.