[Bug middle-end/59970] New: Bogus warnings at low optimization levels
tschwinge at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 28 21:06:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59970
Bug ID: 59970
Summary: Bogus warnings at low optimization levels
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: middle-end
Assignee: tschwinge at gcc dot gnu.org
Reporter: tschwinge at gcc dot gnu.org
Build: x86_64-linux-gnu
Created attachment 31970
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31970&action=edit
cp-demangle.c
The attached code is greatly reduced from libiberty/cp-demangle.c. As
discussed in
<http://news.gmane.org/find-root.php?message_id=%3C87bnyw41hf.fsf%40kepler.schwinge.homeip.net%3E>,
with trunk r207200, it exhibits the following behavior:
$ for t in '' -DTOGGLE1; do for a in '' -DABORT; do for o in -O0 -Og -O1
-O2 -O3 -Ofast; do (set -x && gcc/xgcc -Bgcc/ -Wall -Wextra -c
../../cp-demangle.c $t $a $o); done; done; done
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -O0
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -Og
../../cp-demangle.c: In function 'd_demangle_callback':
../../cp-demangle.c:40:3: warning: 'dc' may be used uninitialized in this
function [-Wmaybe-uninitialized]
return dc;
^
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -O1
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -O2
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -O3
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -Ofast
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DABORT -O0
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DABORT -Og
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DABORT -O1
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DABORT -O2
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DABORT -O3
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DABORT -Ofast
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -O0
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -Og
../../cp-demangle.c: In function 'd_demangle_callback':
../../cp-demangle.c:40:3: warning: 'dc' may be used uninitialized in this
function [-Wmaybe-uninitialized]
return dc;
^
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -O1
../../cp-demangle.c: In function 'd_demangle_callback':
../../cp-demangle.c:40:3: warning: 'dc' may be used uninitialized in this
function [-Wmaybe-uninitialized]
return dc;
^
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -O2
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -O3
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -Ofast
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -DABORT
-O0
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -DABORT
-Og
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -DABORT
-O1
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -DABORT
-O2
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -DABORT
-O3
+ gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -DABORT
-Ofast
In certain cases, GCC fails to track that all the possible values for enum type
indeed have been covered, and so dc must have been initialized.
It does seem appropriate to me for GCC not to do such tracking at low
optimization levels, but then the uninitialized warning should also be disabled
(which I assume is happening for -O0?) to avoid false positive warnings.
The abort to libiberty/cp-demangle.c has been added in r207200. The
libgomp/env.c change r203514 looks like another instance of this issue,
<http://news.gmane.org/find-root.php?message_id=%3C20131014082733.GF30970%40tucnak.zalov.cz%3E>.
I'm assigning this to me, tentatively, low priority, so if someone has any
clues, don't hesititate to take it over.
More information about the Gcc-bugs
mailing list