https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106456
Bug ID: 106456 Summary: -Wunreachable-code seems very broken Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: dcb314 at hotmail dot com Target Milestone: --- I tried out this simple example: extern void g( int); int f( int a) { return 2 * a; g( a); } gcc doesn't seem able to find the problem: $ /home/dcb/gcc/results/bin/g++ -c -g -O2 -Wall -Wextra -Wunreachable-code jul27d.cc $ clang++ can: $ clang++ -c -g -O2 -Wall -Wextra -Wunreachable-code jul27d.cc jul27d.cc:7:2: warning: code will never be executed [-Wunreachable-code] g( a); ^ 1 warning generated. $ Following on from this, there are a couple of examples in the gcc source code: trunk.git/gcc/value-range-storage.h:149:3: style: Statements following return, break, continue, goto or throw will never be executed. [unreachableCode] trunk.git/gcc/value-range-storage.h:210:3: style: Statements following return, break, continue, goto or throw will never be executed. [unreachableCode]