From patchwork Tue Sep 8 13:03:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 515398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 936FF140187 for ; Tue, 8 Sep 2015 23:03:34 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=cmZ6CWuG; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=gQuqUmRkqKIVM+kJH/YbuPPsaeLBniqXjUW1k4ECzl+gZjo+Pk B3xXydoM2F/zgpH6CWUwtm1uXGaCns3pYqoLPxfn8oVaukzMRaaK9yBOmTOPnebz AMus/xY6zW0bzeWrwE0Ylhek1dQeuRMesMwh8FF18cdZhixLNevTp8Rvw= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=vr/JjRl3M2RT6Ba0eKQ9S0D4MS8=; b=cmZ6CWuGpYyooXk3blYV rmSzxpICLXcSNwcKXfMwoeEveflwVvt4LAMj6LlYz8F12jhbR54mPMhJblpJznve NO/7Bs9y2juudQzBsa6rMtfkWZsSW7quYY7vn1Jz6jDAs0RCPXdej6nsOoPCIchf kjS9w2idj4bC/XkzIL4Wthc= Received: (qmail 86616 invoked by alias); 8 Sep 2015 13:03:28 -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 86599 invoked by uid 89); 8 Sep 2015 13:03:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 08 Sep 2015 13:03:27 +0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t88D3PjV023082 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 8 Sep 2015 13:03:25 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t88D3OFp005608 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 8 Sep 2015 13:03:25 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t88D3OJS015199; Tue, 8 Sep 2015 13:03:24 GMT Received: from [192.168.1.4] (/87.16.226.135) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 08 Sep 2015 06:03:24 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 67369 ("[5/6 Regression] ICE (in tsubst_decl, at cp/pt.c:11302) with -std=c++14") Message-ID: <55EEDC97.4010707@oracle.com> Date: Tue, 8 Sep 2015 15:03:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, in this regression, an ICE is triggered in tsubst_decl, [case FUNCTION_DECL] at: /* Nobody should be tsubst'ing into non-template functions. */ gcc_assert (DECL_TEMPLATE_INFO (t) != NULL_TREE); indeed, 't' is just the 'main' function. A simple way to avoid it is tweaking the code recently changed in tsubst_copy, [case FUNCTION_DECL] which calls tsubt_decl via tsusbt, to the effect of not calling the latter at all when DECL_CONTEXT (t) isn't a template. Tested x86_64-linux. Thanks, Paolo. ///////////////// /cp 2015-09-08 Paolo Carlini PR c++/67369 * pt.c (tsubst_copy, [case FUNCTION_DECL]): Do not call tsubst if the first argument isn't a template. /testsuite 2015-09-08 Paolo Carlini PR c++/67369 * g++.dg/cpp1y/lambda-generic-ice4.C: New. Index: cp/pt.c =================================================================== --- cp/pt.c (revision 227528) +++ cp/pt.c (working copy) @@ -13599,8 +13599,9 @@ tsubst_copy (tree t, tree args, tsubst_flags_t com if (r) { /* Make sure that the one we found is the one we want. */ - tree ctx = tsubst (DECL_CONTEXT (t), args, - complain, in_decl); + tree ctx = DECL_CONTEXT (t); + if (DECL_LANG_SPECIFIC (ctx) && DECL_TEMPLATE_INFO (ctx)) + ctx = tsubst (ctx, args, complain, in_decl); if (ctx != DECL_CONTEXT (r)) r = NULL_TREE; } Index: testsuite/g++.dg/cpp1y/lambda-generic-ice4.C =================================================================== --- testsuite/g++.dg/cpp1y/lambda-generic-ice4.C (revision 0) +++ testsuite/g++.dg/cpp1y/lambda-generic-ice4.C (working copy) @@ -0,0 +1,10 @@ +// PR c++/67369 +// { dg-do compile { target c++14 } } + +int main() { + unsigned const nsz = 0; + auto repeat_conditional = [&](auto) { + auto new_sz = nsz; + }; + repeat_conditional(1); +}