https://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|should not warning with |should not warn in dead |dead code |code CC| |msebor at gcc dot gnu.org --- Comment #34 from Martin Sebor <msebor at gcc dot gnu.org> --- (In reply to Niels Möller from comment #32) The front ends can eliminate simple subexpressions (as in '0 ? x >> 32 : x >> 1') but they don't do the same for statements. Moving the warning from the front end to some later pass would avoid diagnosing code in those cases (it would also avoid duplicating the same code between different front ends). The earliest is probably gimplify.c. That would avoid warning on statements rendered dead as a result of constant expressions (as defined by the language) but not those whose constant value GCC later propagates from prior assignments, such as in const int zero = 0; unsigned shift_dead (unsigned x) { if (zero) return x >> 32; else return x >> 1; } The later the warning is moved the more statements will be eliminated as dead, but the more other transformations will also be applied that might eliminate the warning where it might be desirable, or perhaps even introduce it where it wouldn't be issued otherwise.