From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19032 invoked by alias); 27 Oct 2008 12:24:23 -0000 Received: (qmail 16018 invoked by uid 48); 27 Oct 2008 12:23:02 -0000 Date: Mon, 27 Oct 2008 12:24:00 -0000 Message-ID: <20081027122302.16017.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/36254] wrong "control reaches end of non-void function" warning In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jakub at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-10/txt/msg01732.txt.bz2 ------- 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