From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5607 invoked by alias); 2 Feb 2008 17:47:51 -0000 Received: (qmail 5437 invoked by uid 48); 2 Feb 2008 17:47:08 -0000 Date: Sat, 02 Feb 2008 17:47:00 -0000 Message-ID: <20080202174708.5436.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/35056] [4.3 Regression] ICE in copy_to_mode_reg, at explow.c:621 In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "matz 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-02/txt/msg00259.txt.bz2 ------- Comment #10 from matz at gcc dot gnu dot org 2008-02-02 17:47 ------- A TARGET_EXPR has the following semantics: (1) If it's a RHS of a MODIFY_STMT (or similar), i.e.: lhs = TARGET_EXPR this is (for gimplifying) the same as lhs = init except when TREE_TYPE(init) is void, in that case the init tree is expected to magically set 'slot' when evaluated. (2) If it's not the RHS of something, i.e. in a toplevel stmt for instance, then this is equivalent to: slot = init (again, except when 'init' has void type). Let's ignore the case that 'init' has void type, then 'init' is an expression, and the semantics of TARGET_EXPR are the same as temp = init This is only valid when useless_type_conversion(TREE_TYPE(temp), TREE_TYPE(init)) . Hence I think for all TARGET_EXPRs created, for which init hasn't void type, the above predicate has to hold. I think this is best ensured in the lowest functions which create TARGET_EXPR, not in the high-level users. Hence I think the safest would be to modify build_target_expr directly, with something like this: Index: cp/tree.c =================================================================== --- cp/tree.c (Revision 132064) +++ cp/tree.c (Arbeitskopie) @@ -259,6 +259,11 @@ build_target_expr (tree decl, tree value { tree t; + if (!VOID_TYPE_P (TREE_TYPE (value)) + && TREE_TYPE (decl) != TREE_TYPE (value) + && !useless_type_conversion_p (TREE_TYPE (decl), TREE_TYPE (value))) + value = fold_convert (TREE_TYPE (decl), value); + t = build4 (TARGET_EXPR, TREE_TYPE (decl), decl, value, cxx_maybe_build_cleanup (decl), NULL_TREE); /* We always set TREE_SIDE_EFFECTS so that expand_expr does not -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35056