It is not possible to force gcc to ignore unreachable code and statuses that have no effect.
What you can do is make the unreachable code seem to be accessible using mutable variables.
volatile bool always_true = true; if( always_true ) { //infinite loop //return something } //Useless code
in the above example, gcc will not fertilize useless code because it cannot know that it is useless
int a = 5; int b = 5; volatile int c = 9; c += 37; return a + b;
In this example, the integer c will not be optimized, because gcc cannot know that this is dead weight code.
8bitwide
source share