Bug 81329 - Missing -Wmaybe-uninitialized warning
Summary: Missing -Wmaybe-uninitialized warning
Status: RESOLVED DUPLICATE of bug 18501
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 7.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2017-07-05 21:06 UTC by Tudor Bosman
Modified: 2017-11-08 00:46 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Missed maybe-uninitialized warning: test case (151 bytes, text/plain)
2017-07-05 21:06 UTC, Tudor Bosman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tudor Bosman 2017-07-05 21:06:43 UTC
Created attachment 41689 [details]
Missed maybe-uninitialized warning: test case

The attached test case should warn, as foo is used uninitialized if the "atoi(argv[1]) != 0" branch isn't taken. There are no warnings, even with "-Wall -Wextra".

Tested with gcc 7.1, both with -O0 and with -O3, see https://godbolt.org/g/J5wRSM
Comment 1 Andrew Pinski 2017-07-05 21:18:05 UTC
There are a few duplicates of this bug floating around.
Comment 2 Tudor Bosman 2017-07-05 21:25:27 UTC
(In reply to Andrew Pinski from comment #1)
> There are a few duplicates of this bug floating around.

I figured, but I don't know anything about gcc internals to tell which of these duplicates are the same bug and which are different (same symptom, different internal cause).
Comment 3 Manuel López-Ibáñez 2017-11-08 00:46:56 UTC
foo is assumed initialized to 1 by CCP and the whole "atoi(argv[1]) != 0" branch is optimized away. -O0 does not warn because initialization is conditional.

*** This bug has been marked as a duplicate of bug 18501 ***