------- Comment #8 from jakub at gcc dot gnu dot org 2008-10-27 12:23 ------- The problem is that during gimplification shortcut_cond_expr doesn't detect that then_ can't fallthru, if it detected that, then no jump around the else block would be added and control reaches end of non-void function wouldn't be diagnosed. shortcut_cond_expr calls block_may_fallthru, unfortunately in C++ then then_ block isn't something block_may_fallthru handles - it is IF_STMT in the first testcase, which is a C++ specific tree. To fix this, either we'd need to do short cut on tuples (where gimple_seq_may_fallthru handles all the gimple codes correctly), but I guess that's quite hard, or we'd need some flag with which shortcut_cond_expr would mark the maybe not needed GOTO_EXPR + LABEL_EXPR and during gimplification see if sequence before so marked GOTO_EXPR might fallthru and if not, don't add the GIMPLE_GOTO nor GIMPLE_LABEL. Or block_may_fallthru would need to call a langhook to handle unknown cases and each frontend would need to say what can and what can't fallthru from the lang specific tree codes.
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36254