https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101768
Andrew Pinski changed:
What|Removed |Added
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Keywords||diagnostic
Last reconfirmed||2021-08-03
Summary|-Wmaybe-uninitialized false |-Wmaybe-uninitialized false
|alarm with 'switch' instead |alarm with non local
|of 'if' |variables in some cases
--- Comment #2 from Andrew Pinski ---
here is a reduced testcase:
int ct;
void foo (int);
int
cmp (int arg)
{
int differing = 0;
int offset_width;
if (ct == 1)
{
offset_width = 1;
for (offset_width = 1; (arg /= 10) != 0; offset_width++)
;
}
do {
if (ct == 1) {
foo (offset_width);
differing--;
}
} while (differing <= 0);
return !!differing;
}
GCC does not figure out once ct == 1, and foo is called, it will either become
ct == 1 which is fine or never be ct == 1 again.