http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60165
Bug ID: 60165
Summary: "may be used uninitialized" warning with -O3 but not
with -O2
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: vincent-gcc at vinc17 dot net
With:
gcc (Debian 20140111-1) 4.9.0 20140111 (experimental) [trunk revision 206552]
I get the following inconsistency in the warnings:
ypig% cat out.i
int a, b;
int fn2 (int, int);
int fn1 (int *p1)
{
if (fn2 (a, 0))
*p1 = b;
int c;
fn1 (&c);
return c;
}
ypig% gcc-snapshot -c -Wall -Werror=maybe-uninitialized -O2 out.i
ypig% gcc-snapshot -c -Wall -Werror=maybe-uninitialized -O3 out.i
out.i: In function 'fn1':
out.i:9:5: error: 'c' may be used uninitialized in this function
[-Werror=maybe-uninitialized]
return c;
^
cc1: some warnings being treated as errors
ypig%
I don't know whether this is regarded as normal, but this looks strange.
Note: I got this problem when compiling round_prec.c from the GNU MPFR trunk. I
generated the preprocessed file with -E, then used creduce on the following
script:
#!/bin/sh
{
gcc-snapshot -c -Wall -Werror=maybe-uninitialized -O2 out.i && \
! gcc-snapshot -c -Wall -Werror=maybe-uninitialized -O3 out.i
} >/dev/null 2>&1
to generate the simple testcase (and fixed the declarations to avoid additional
warnings -- I think I should have used -Werror in the script to avoid them in
the first place).