It\'s common for compilers to provide a switch to warn when code is unreachable. I\'ve also seen macros for some libraries, that provide assertions for unreachable code.
With gcc 4.4.0 Windows cross compiler to PowerPC compiling with -O2 or -O3 the following works for me:
#define unreachable asm("unreachable\n")
The assembler fails with unknown operation if the compiler doesn't optimise it away because it has concluded that it is unreachable.
Yes, it is quite probably `highly unpredictable under different optimization options', and likely to break when I finally update the compiler, but for the moment it's better then nothing.