[Bug tree-optimization/106155] New: [12/13 Regression] spurious "may be used uninitialized" warning
vincent-gcc at vinc17 dot net
gcc-bugzilla@gcc.gnu.org
Fri Jul 1 01:49:32 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106155
Bug ID: 106155
Summary: [12/13 Regression] spurious "may be used
uninitialized" warning
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: vincent-gcc at vinc17 dot net
Target Milestone: ---
With "-O -Wmaybe-uninitialized", I get a spurious "may be used uninitialized"
on the following code on an x86_64 Debian/unstable machine:
int *e;
int f1 (void);
void f2 (int);
long f3 (void *, long, int *);
void f4 (void *);
int *fh;
void tst (void)
{
int status;
unsigned char badData[3][3] = { { 7 }, { 16 }, { 23 } };
int badDataSize[3] = { 1, 1, 1 };
int i;
for (i = 0; i < 3; i++)
{
int emax;
if (i == 2)
emax = f1 ();
status = f3 (&badData[i][0], badDataSize[i], fh);
if (status)
{
f1 ();
f1 ();
f1 ();
}
f4 (fh);
*e = 0;
f1 ();
if (i == 2)
f2 (emax);
}
}
Note that even a small change such as changing "long" to "int" as the second
parameter of f3 makes the warning disappear.
$ gcc-12 -O -Wmaybe-uninitialized -c -o tfpif.o tfpif.c
tfpif.c: In function ‘tst’:
tfpif.c:31:9: warning: ‘emax’ may be used uninitialized [-Wmaybe-uninitialized]
31 | f2 (emax);
| ^~~~~~~~~
tfpif.c:17:11: note: ‘emax’ was declared here
17 | int emax;
| ^~~~
$ gcc-12 --version
gcc-12 (Debian 12.1.0-5) 12.1.0
[...]
$ gcc-snapshot -O -Wmaybe-uninitialized -c -o tfpif.o tfpif.c
tfpif.c: In function 'tst':
tfpif.c:31:9: warning: 'emax' may be used uninitialized [-Wmaybe-uninitialized]
31 | f2 (emax);
| ^~~~~~~~~
tfpif.c:17:11: note: 'emax' was declared here
17 | int emax;
| ^~~~
$ gcc-snapshot --version
gcc (Debian 20220630-1) 13.0.0 20220630 (experimental) [master
r13-1359-gaa1ae74711b]
[...]
No such issue with:
gcc-9 (Debian 9.5.0-1) 9.5.0
gcc-10 (Debian 10.4.0-1) 10.4.0
gcc-11 (Debian 11.3.0-4) 11.3.0
I detected this issue by testing GNU MPFR. The above code is derived from
"tests/tfpif.c", function check_bad.
More information about the Gcc-bugs
mailing list