The gcc
compiler (up to 4.4) had a -Wunreachable-code
option which should catch this.
This wasn't part of the -Wall
group since you're more likely to have unreachable code during the development process, the time when you're most likely to be using -Wall
.
It was removed as of 4.5 due to inconsistencies with the optimiser. By removed, I mean the compiler still accepts the flag but doesn't act on it. I believe Clang still includes that option, since it likes to be compatible with gcc.