https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101768
Bug ID: 101768 Summary: -Wmaybe-uninitialized false alarm with 'switch' instead of 'if' Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: eggert at cs dot ucla.edu Target Milestone: --- Created attachment 51255 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51255&action=edit False alarm with gcc -O2 -Wmaybe-uninitialized The attached program is a greatly-simplified version of GNU diffutils' cmp program. Compiling it this way: gcc -O2 -Wmaybe-uninitialized -S u.i causes gcc to emit the bogus diagnostic: u.i: In function ‘cmp’: u.i:21:11: warning: ‘offset_width’ may be used uninitialized in this function [-Wmaybe-uninitialized] 21 | foo (offset_width); | ^~~~~~~~~~~~~~~~~~ I tried simplifying it further (removing the 'main' function, turning the switch into an if, etc.) but the warning went away with the further simplifications. This is with gcc (GCC) 11.2.1 20210728 (Red Hat 11.2.1-1) on x86-64.