https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119444
Bug ID: 119444
Summary: Missing -Wuninitialized warnings with LTO
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: acoplan at gcc dot gnu.org
Target Milestone: ---
For the following testcase (current trunk, aarch64):
$ cat t.c
int main(void)
{
int x;
for (int i = 0; i < 10; i++)
x += 1;
return x;
}
compiled with -O2 -Wall I get an uninitialized warning, as expected:
$ gcc t.c -O2 -Wall -c -S -o /dev/null
t.c: In function ‘main’:
t.c:3:7: warning: ‘x’ is used uninitialized [-Wuninitialized]
3 | int x;
| ^
but if I instead compile with LTO:
$ gcc t.c -O2 -Wall -flto
there is no warning. This seems somewhat surprising. I would have expected
the warning to show up with LTO, too.