[Bug middle-end/69230] New: valid -Wmaybe-uninitialized suppressed by -O2
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jan 11 19:12:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
Bug ID: 69230
Summary: valid -Wmaybe-uninitialized suppressed by -O2
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
With -O2, versions of gcc going as far back as 4.5.3 all the way to recent
trunk (6.0) issues a -Wmaybe-uninitialized warning for the code below. The bug
appears to be masking a large number of problems in glibc (see
https://sourceware.org/bugzilla/show_bug.cgi?id=19444).
$ (cc=$HOME/bin/gcc-5.1.0/bin/gcc; cat a.c && set -x && $cc -S -o/dev/null -O1
-Wall -Wextra a.c && $cc -O2 -S -Wall -Wextra -o/dev/null a.c)
int foo (int i)
{
int j;
switch (i & 2) {
case 0: j = 1; break;
case 1: j = 2; break;
case 2: j = 3; break;
case 3: j = 4; break;
}
return j + 1;
}
+ /home/msebor/bin/gcc-5.1.0/bin/gcc -S -o/dev/null -O1 -Wall -Wextra a.c
a.c: In function ‘foo’:
a.c:11:12: warning: ‘j’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
return j + 1;
^
+ /home/msebor/bin/gcc-5.1.0/bin/gcc -O2 -S -Wall -Wextra -o/dev/null a.c
More information about the Gcc-bugs
mailing list