Bug 40469 - [4.3/4.4/4.5 Regression] "Missing" uninitialized warning
Summary: [4.3/4.4/4.5 Regression] "Missing" uninitialized warning
Status: RESOLVED DUPLICATE of bug 18501
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
Reported: 2009-06-17 00:04 UTC by Hans-Peter Nilsson
Modified: 2009-06-18 14:30 UTC (History)
20 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
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.