Bug 850712 - -Wuninitialized/-Wmaybe-uninitialized depends on optimization level
Summary: -Wuninitialized/-Wmaybe-uninitialized depends on optimization level
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 17
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-08-22 08:11 UTC by Milan Crha
Modified: 2012-08-22 11:57 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2012-08-22 08:45:33 UTC
Type: Bug
Embargoed:


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

Description Milan Crha 2012-08-22 08:11:12 UTC
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 08:45:33 UTC
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 10:56:53 UTC
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 11:57:29 UTC
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.