From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17344 invoked by alias); 2 Jan 2014 14:49:29 -0000 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 Received: (qmail 17303 invoked by uid 48); 2 Jan 2014 14:49:25 -0000 From: "mpolacek at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/59630] [4.7/4.8/4.9 Regression] ICE converting the return type of a builtin function Date: Thu, 02 Jan 2014 14:49:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mpolacek at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-01/txt/msg00061.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59630 --- Comment #3 from Marek Polacek --- One alternative could be the following (though completely untested): --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -14227,6 +14227,10 @@ fold_call_stmt (gimple stmt, bool ignore) of a builtin, will use the wrong location information. */ if (gimple_has_location (stmt)) { + tree lhs = gimple_call_lhs (stmt); + if (lhs && !useless_type_conversion_p (TREE_TYPE (lhs), + TREE_TYPE (ret))) + return NULL_TREE; tree realret = ret; if (TREE_CODE (ret) == NOP_EXPR) realret = TREE_OPERAND (ret, 0);