https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89909
Bug ID: 89909 Summary: false positive for for -Wunreachable-code. Product: gcc Version: 8.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: pawel_sikora at zoho dot com Target Milestone: --- #include <cstdio> void foo( int i ) { char const* j = nullptr; switch ( i ) { if ( 0 ) { case 1: j = "one"; } if ( 0 ) { case 2: j = "two"; } { std::printf( "%s\n", j ); return; } default: std::puts( "unknown" ); }; } int main() { foo( 0 ); foo( 1 ); foo( 2 ); foo( 3 ); return 0; } // g++ (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2) % g++ t.cpp -Wall -Wunreachable-code -o t && ./t t.cpp: In function ‘void foo(int)’: t.cpp:8:9: warning: statement will never be executed [-Wswitch-unreachable] if ( 0 ) { ^~ unknown one two unknown