User account creation filtered due to spam.

Bug 40469

Summary: [4.3/4.4/4.5 Regression] "Missing" uninitialized warning
Product: gcc Reporter: Hans-Peter Nilsson <hp>
Component: cAssignee: Not yet assigned to anyone <unassigned>
Severity: normal CC: christoph.mallon, david.cuthbert, dberlin, dhill, dnovillo, fang, fredrik, gcc-bugs, hp, jellegeerts, jens.mueller, manu, mark, mueller, muntyan, P.Schaffnit, pinskia, rguenth, satyam, thutt
Priority: P3    
Version: 4.5.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:
Bug Depends on:    
Bug Blocks: 24639    

Description Hans-Peter Nilsson 2009-06-17 00:04:58 UTC
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.

bar(int foo)
  int res;

  if (foo) {
  } else {
    res = 0;
  return res;

  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.
Comment 1 Richard Biener 2009-06-17 11:47:35 UTC
It is.

*** This bug has been marked as a duplicate of 22456 ***
Comment 2 Manuel López-Ibáñez 2009-06-17 12:02:07 UTC
No, it is not. There is no loop here, this is CCP assuming that res is 0 always.

Comment 3 Manuel López-Ibáñez 2009-06-17 12:03:25 UTC
... so this is actually a duplicate of bug 18501.

*** This bug has been marked as a duplicate of 18501 ***
Comment 4 Hans-Peter Nilsson 2009-06-18 05:49:00 UTC
(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.
Comment 5 Manuel López-Ibáñez 2009-06-18 08:16:40 UTC
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?
Comment 6 Hans-Peter Nilsson 2009-06-18 14:30:12 UTC
(In reply to comment #5)
> See the difference now?

Thanks, that helped.