https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80460
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |mpolacek at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The warning is done before optimizations (except GENERIC opts), and can hardly be done much later. In *.original we have: case 0:; <<cleanup_point <<< Unknown tree: expr_stmt if (1) { qt_assert (); } else { qt_noop (); } >>>>>; case 1:; <<cleanup_point <<< Unknown tree: expr_stmt qt_noop () >>>>>; and what the warning code sees in *.gimple when it is performed is: switch (i) <default: <D.2284>, case 0: <D.2278>, case 1: <D.2279>> <D.2278>: if (1 != 0) goto <D.2282>; else goto <D.2283>; <D.2282>: qt_assert (); <D.2283>: qt_noop (); <D.2279>: qt_noop (); <D.2284>: So, to get rid of the warning, we'd need to do some optimization already during the gimplification, perhaps if we have COND_EXPR with constant condition scan the non-active branch and if there are no labels in there, don't try to gimplify it at all? Walking it for all COND_EXPRs with constant condition would have undesirable compile time complexity though if there are any labels. And trying to prove if some code is reachable or not reachable at gimplification time is not really doable, we don't have CFG. Moving the warning later is also undesirable, because the IL would be mangled and wouldn't match the original source the way we need.