https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71249
Bug ID: 71249 Summary: -Wswitch-unreachable false positive for a compound statement containing a used label Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- While reading the changes that implement the new -Wswitch-unreachable option (bug 49859) I noticed that the hunk in gimplify_switch_exp assumes that only GIMPLE_LABEL and LABEL_TRY statements are reachable. The following test case shows that this is an overly broad assumption, and that compound statements containing labels used labels as their second or subsequent statements can also be reachable. As a result, GCC issues a false positive warning for the following test case: $ cat xxx.c && /build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -S -Wall xxx.c int g (int i) { switch (i) { { i = 0; foo: return i; } case 3: goto foo; } return i; } xxx.c: In function āgā: xxx.c:4:7: warning: statement will never be executed [-Wswitch-unreachable] { i = 0; foo: return i; } ~~^~~