https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94963
Bug ID: 94963 Summary: [11 Regression] Spurious uninitialized warning for static variable building glibc Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jsm28 at gcc dot gnu.org Target Milestone: --- r11-39-gf9e1ea10e657af9fb02fafecf1a600740fd34409 ("tree-optimization/39612 - avoid issueing loads in SM when possible") introduces a spurious warning building the following code (reduced from glibc) with -O2 -Wall (for aarch64-linux-gnu at least, probably for other targets. The warning is obviously bogus because it relates to a field of a static variable, which is always initialized. uninit.c: In function 'f': uninit.c:30:6: warning: 'var_field_lsm.8' may be used uninitialized in this function [-Wmaybe-uninitialized] 30 | if (var.field != 0) | ^ Reduced testcase: typedef struct { int p1; int p2; int p3; } P; struct S { int field; }; extern int v2; extern void foo (struct S *map); static struct S var; const P *pv; int ps; void f (void) { if (pv != 0) for (const P *ph = pv; ph < &pv[ps]; ++ph) switch (ph->p1) { case 1: v2 = ph->p2; break; case 2: var.field = ph->p3; break; } if (var.field != 0) foo (&var); }