https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99756
Bug ID: 99756 Summary: bogus -Wmaybe-uninitialized with a use conditional that's a subset of a defining conditional Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The following code triggers a spurious -Wmaybe-uninitialized. There are two underlying problems: one is a limitation of the uninitialized pass and another is a missed optimization opportunity described in PR 99755 (the second test for k results in another read from it instead of reusing the value read previously in the first conditional). $ cat t.c && gcc -O2 -S -Wall t.c extern int a[], i, j, k; void f (void) { int x; if (i > 1 && j > 2 && k > 3) x = i + 1; if (i == 2 && j == 3 && k == 4) a[x] = 0; // { dg-bogus "Wmaybe-uninitialized" } } t.c: In function ‘f3’: t.c:28:10: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized] 28 | a[x] = 0; // { dg-bogus "Wmaybe-uninitialized" } | ~~~~~^~~