[Bug middle-end/80548] New: -Wmaybe-uninitialized false positive when an assignment is added
vincent-gcc at vinc17 dot net
gcc-bugzilla@gcc.gnu.org
Thu Apr 27 15:36:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80548
Bug ID: 80548
Summary: -Wmaybe-uninitialized false positive when an
assignment is added
Product: gcc
Version: 6.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: vincent-gcc at vinc17 dot net
Target Milestone: ---
Consider:
int g (void);
void h (int, int);
void f (int b)
{
int x, y;
if (b)
{
x = g ();
y = g ();
}
while (g ())
if (b)
{
h (x, y);
y = g ();
}
}
Compiling this program with "-O -Wmaybe-uninitialized -c" yields:
tst.c: In function ‘f’:
tst.c:17:9: warning: ‘y’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
h (x, y);
^~~~~~~~
Note that x and y play a symmetric role here, except that y has an additional
assignment, and this assignment makes GCC think that y may be used
uninitialized! Indeed, if one removes this assignment, the warning disappear.
More information about the Gcc-bugs
mailing list