From patchwork Mon Feb 19 18:56:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 875292 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-473554-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="w+iiI3R4"; 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 3zlZ8z1rsqz9s0r for ; Tue, 20 Feb 2018 06:50:11 +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:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=mBP3/2NuZ7cbUDw480B4alYwa3HCg R/eLCcODeA3zkIsS90Q1a21lV/ghY6/afF0rRnhO10xdvAtFEE3BUdaV+4tPxTDW o7LpDDhVRT+wH+9Fh06HrEUdmLqzb8OIWIbOLfVLFR8/he2LstolKob6snkZj7R7 H7j0K9gxBy4Rg0= 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:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=UAtxWMMj+A9HR+gN+SMrq1KYva8=; b=w+i iI3R46IliaiyuZG2K+DR60tkMkkIKqHqm2S0yNbl7nKPAq7rISPe17LNkn8d8heG oM4fZ236Z8Sud4uHXi3qvjkFLGXPyYkodfIxiLETe/o2ug+k+/SsAvruiTqtl4aB Il3Jv+1q3PJibYJ7qWp5aRsOWHI1uwMYSxhXSAJU= Received: (qmail 3319 invoked by alias); 19 Feb 2018 19:49:45 -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 3167 invoked by uid 89); 19 Feb 2018 19:49:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-12.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Feb 2018 19:49:42 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E5244023EDE for ; Mon, 19 Feb 2018 19:49:30 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-85.brq.redhat.com [10.40.204.85]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB1BD2166BAE for ; Mon, 19 Feb 2018 19:49:29 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w1JIuSu7025098; Mon, 19 Feb 2018 19:56:28 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w1JIuQXY025097; Mon, 19 Feb 2018 19:56:26 +0100 Date: Mon, 19 Feb 2018 19:56:26 +0100 From: Jakub Jelinek To: Jason Merrill , Nathan Sidwell Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix GC lambda ICE (PR c++/84455) Message-ID: <20180219185626.GN5867@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) X-IsSubscribed: yes Hi! While cp_parser_lambda_body which is the other finish_lambda_function caller next to tsubst_lambda_expr temporarily increments function_depth around that call (if not nested) to avoid GC during expand_or_defer_fn from finish_lambda_function, tsubst_lambda_expr doesn't, and on the lambda-ice14.C we can see the GC in action in that case. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-02-19 Jakub Jelinek PR c++/84455 * pt.c (tsubst_lambda_expr): If not nested, increment temporarily function_depth to avoid GC during finish_lambda_function. * g++.dg/cpp0x/lambda/lambda-ice26.C: New test. Jakub --- gcc/cp/pt.c.jj 2018-02-16 23:37:29.312364263 +0100 +++ gcc/cp/pt.c 2018-02-19 10:48:00.328184302 +0100 @@ -17070,6 +17070,10 @@ tsubst_lambda_expr (tree t, tree args, t bool nested = cfun; if (nested) push_function_context (); + else + /* Still increment function_depth so that we don't GC in the + middle of an expression. */ + ++function_depth; local_specialization_stack s (lss_copy); @@ -17084,6 +17088,8 @@ tsubst_lambda_expr (tree t, tree args, t if (nested) pop_function_context (); + else + --function_depth; /* The capture list was built up in reverse order; fix that now. */ LAMBDA_EXPR_CAPTURE_LIST (r) --- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice26.C.jj 2018-02-19 10:51:24.838188732 +0100 +++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice26.C 2018-02-19 10:51:19.690188624 +0100 @@ -0,0 +1,5 @@ +// PR c++/84455 +// { dg-do compile { target c++11 } } +// { dg-options "--param ggc-min-heapsize=0" } + +#include "lambda-ice14.C"