https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82101
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|FIXED |---
Known to fail| |10.2.0, 11.0, 7.3.0, 8.3.0,
| |9.2.0
Last reconfirmed|2017-09-05 00:00:00 |2021-4-2
Status|RESOLVED |NEW
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Let me take that back. The complaint is about the missing warning for the
variable in the loop, not the one outside it, and presumably with -O1 or above.
That's not quite clear from the description.
Here's a test case for the problem. It's never been diagnosed:
$ cat pr82101.C && gcc -O1 -S -Wall pr82101.C
void f (int);
void g (void)
{
for (int i = 0; i < 10; i++)
{
int t = t; // -Wuninitialized
f (t);
}
}
void h (void)
{
for (int i = 0; i < 10; i++)
{
int t = t; // missing warning
}
}
pr82101.C: In function ‘void g()’:
pr82101.C:8:9: warning: ‘t’ is used uninitialized [-Wuninitialized]
8 | f (t);
| ~~^~~
pr82101.C:7:11: note: ‘t’ was declared here
7 | int t = t; // -Wuninitialized
| ^