From patchwork Mon Jan 14 02:11:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 1024270 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-493975-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="XOQiVp1I"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43dH5n58X8z9s4s for ; Mon, 14 Jan 2019 13:11:41 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=GTy3X+24D7A20fkmcB2uzcJLL7dfnu+fcFvWwhZ4ii0t/hec5l7KG TOciDejPWUVeqGB/Va8v1BmLThgOvvsBKybUX6nT3cv4pvstMaSALR48YChOidPU lGXV6dSOZdJzsexKxbz9pQSUphuGszdEfyjZ7uLWvl8X1GR2qDrElk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=K4+zEiXbQ1hNKLXjI0YeXMjTeyg=; b=XOQiVp1ITBUyYHQHlvkw G9BcjnwMOZ9PTQofRN+UZHPgh13sWzO/ODUdX64aOzOYifQm8/vE9P9PNrO5qG6W 5eLkhXkemmPJFkppRzsFzO/b/S6kMo4AEzk4ci79Pf3q6KcPpQPwH1Xn2mv0VH+T nPkr+t/V87gU/FGSkdB08lU= Received: (qmail 60268 invoked by alias); 14 Jan 2019 02:11:34 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 60247 invoked by uid 89); 14 Jan 2019 02:11:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Jan 2019 02:11:33 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD224811C0 for ; Mon, 14 Jan 2019 02:11:31 +0000 (UTC) Received: from redhat.com (ovpn-120-242.rdu2.redhat.com [10.10.120.242]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4373271D46; Mon, 14 Jan 2019 02:11:31 +0000 (UTC) Date: Sun, 13 Jan 2019 21:11:34 -0500 From: Marek Polacek To: GCC Patches , Jason Merrill Subject: C++ PATCH for c++/88825 - ICE with bogus function return type deduction Message-ID: <20190114021134.GC19569@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) In this (invalid) testcase the return type deduction failed so FUNCTYPE was error_mark_node and can_do_nrvo_p crashed. One way to fix this would be to check error_operand_p as below. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2019-01-13 Marek Polacek PR c++/88825 - ICE with bogus function return type deduction. * typeck.c (can_do_nrvo_p): Check error_operand_p. * g++.dg/cpp1y/auto-fn55.C: New test. diff --git gcc/cp/typeck.c gcc/cp/typeck.c index 43d2899a3c4..3d3049cc3a0 100644 --- gcc/cp/typeck.c +++ gcc/cp/typeck.c @@ -9342,6 +9342,8 @@ is_std_move_p (tree fn) static bool can_do_nrvo_p (tree retval, tree functype) { + if (error_operand_p (functype)) + return false; if (retval) STRIP_ANY_LOCATION_WRAPPER (retval); tree result = DECL_RESULT (current_function_decl); diff --git gcc/testsuite/g++.dg/cpp1y/auto-fn55.C gcc/testsuite/g++.dg/cpp1y/auto-fn55.C new file mode 100644 index 00000000000..aea2740e1f5 --- /dev/null +++ gcc/testsuite/g++.dg/cpp1y/auto-fn55.C @@ -0,0 +1,8 @@ +// PR c++/88825 +// { dg-do compile { target c++14 } } + +auto f () -> auto * +{ + int t = 0; + return t; // { dg-error "unable to deduce" } +}