From patchwork Wed Nov 22 14:49:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 840436 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-467698-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="T5Zc88lv"; 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 3yhlht65Jvz9s72 for ; Thu, 23 Nov 2017 01:49:18 +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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=SdqXBOHbklnR4TJZ2W2jlh6wBOr34Lp9zGA6UDR/iED4WWFE3F JaKN3axeyn0bIT8r3qg2dTID8ek8EEKEY4Pz2LNrSC+uMs5OrnJvq1T/IfeqcT8B A/LcRFVUGFNFpbK8l2G2DyvMwz5RNf5rW1tohU/qKtYSFmitvqUAQwPFQ= 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=tKSbGRF90jCyKBdpeeG3td3sOLs=; b=T5Zc88lvSJBnIjhoQMEN JSKHZTINSOYkBmsoziyCZNHXcFob1VfrKg7Ls1hWTYvBCyJrzMSsFe0BbdmE0H4y sF57/AGjSr6mhNuedSMHtDGGga2WyFERbRxsFPm0UzdYoGQUe5lwhrS+xcpQFOFt ghzgTrlxI5o7Sm60EBTCOag= Received: (qmail 121870 invoked by alias); 22 Nov 2017 14:49:11 -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 121860 invoked by uid 89); 22 Nov 2017 14:49:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1916 X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Nov 2017 14:49:09 +0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vAMEn6Nb010293 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Nov 2017 14:49:06 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vAMEn50v023494 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Nov 2017 14:49:05 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vAMEn5te031900; Wed, 22 Nov 2017 14:49:05 GMT Received: from [192.168.1.4] (/79.53.237.72) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 22 Nov 2017 06:49:04 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill , Nathan Sidwell From: Paolo Carlini Subject: [C++ Patch] PR 82293 ("[8 Regression] ICE in nonlambda_method_basetype at gcc/cp/lambda.c:886") Message-ID: Date: Wed, 22 Nov 2017 15:49:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, this ICE on valid is triggered by the existing cpp0x/lambda/lambda-ice20.C when -Wshadow is requested. Today I confirmed that it can be reproduced only after r251433, the "Reimplement handling of lambdas in templates." patch: then, as part of tsubst_lambda_expr, do_pushdecl calls check_local_shadow which in turn checks nonlambda_method_basetype and at that time current_class_type is null. I believe this is just something which we have to handle in the obvious way: indeed, most other uses of LAMBDA_TYPE_P are already checking first that the argument is non-null, see, for example, the related current_nonlambda_class_type. Tested x86_64-linux. Thanks, Paolo. /////////////////////// /cp 2017-11-22 Paolo Carlini PR c++/82293 * lambda.c (nonlambda_method_basetype): Don't use LAMBDA_TYPE_P on a null type. /testsuite 2017-11-22 Paolo Carlini PR c++/82293 * g++.dg/cpp0x/lambda/lambda-ice24.C: New. Index: cp/lambda.c =================================================================== --- cp/lambda.c (revision 255053) +++ cp/lambda.c (working copy) @@ -921,7 +921,7 @@ nonlambda_method_basetype (void) return NULL_TREE; type = current_class_type; - if (!LAMBDA_TYPE_P (type)) + if (!type || !LAMBDA_TYPE_P (type)) return type; /* Find the nearest enclosing non-lambda function. */ Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice24.C =================================================================== --- testsuite/g++.dg/cpp0x/lambda/lambda-ice24.C (nonexistent) +++ testsuite/g++.dg/cpp0x/lambda/lambda-ice24.C (working copy) @@ -0,0 +1,12 @@ +// PR c++/82293 +// { dg-do compile { target c++11 } } +// { dg-options "-Wshadow" } + +template +struct S { + int f{[this](){return 42;}()}; +}; + +int main(){ + return S{}.f; +}