Bug 850712 - -Wuninitialized/-Wmaybe-uninitialized depends on optimization level
-Wuninitialized/-Wmaybe-uninitialized depends on optimization level
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
17
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-22 04:11 EDT by Milan Crha
Modified: 2012-08-22 07:57 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-08-22 04:45:33 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
test2.c (251 bytes, text/plain)
2012-08-22 04:11 EDT, Milan Crha
no flags Details

  None (edit)
Description Milan Crha 2012-08-22 04:11:12 EDT
Created attachment 606160 [details]
test2.c

Warning about used unitialized variables depends on optimization level. The attached is a test program, which demonstrates the issue. It would be nice to not depend on optimization level here, at least in this case.

This is with gcc-4.7.0-5.fc17.x86_64, and the output based on compilation is here:


$ gcc -g -O0 -Wall -Wextra test2.c -o test2 && ./test2
x:1 p:2
x:0 p:3

$ gcc -g -O2 -Wall -Wextra test2.c -o test2 && ./test2
test2.c: In function ‘main’:
test2.c:14:3: warning: ‘p’ is used uninitialized in this function [-Wuninitialized]
test2.c:7:6: note: ‘p’ was declared here
x:1 p:2
x:0 p:1
Comment 1 Jakub Jelinek 2012-08-22 04:45:33 EDT
That is not a bug.  Warnings that aren't reported by the frontends, but that require some optimizations for it to be performed, obviously do depend on the optimization level.
Comment 2 Milan Crha 2012-08-22 06:56:53 EDT
I do not understand. If you check the code, then there is no compiler optimization required to trigger the use of uninitialized variable.
Comment 3 Jakub Jelinek 2012-08-22 07:57:29 EDT
The uninitialized use is (without inlining/cloning) only conditional, of the may be used uninitialized kind, and for -O0 those are never enabled, because not enough optimizations were performed to remove most of the false positives.

Note You need to log in before you can comment on or make changes to this bug.