From patchwork Tue Jan 21 21:42:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1226777 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-517942-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.a=rsa-sha1 header.s=default header.b=gc3z1tX1; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=B2legXA4; 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 482MSs5qP7z9sR8 for ; Wed, 22 Jan 2020 08:42:20 +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:from :to:subject:date:message-id:content-type :content-transfer-encoding; q=dns; s=default; b=Nn4QdgneLJDomrjD L74TSxtYT5SVn+1bzYj1bcJXJtZKkD7HmY1DI1Fhpe2XzGuWCyxgjBCjhKi8K1WD axTcNrQMtgRzJQ4n49mlE+TnqFmkEzRacV/Z3fyHf+P0PhAzZyLESH+qbzbkynXv V38MXMd9l0xJhj1vi6DJygrmshA= 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:from :to:subject:date:message-id:content-type :content-transfer-encoding; s=default; bh=9zaywgHHIjK6STV3bgrYbA VFMDs=; b=gc3z1tX1DvD1Q0yVpINhgOOYj794cm9dqBvj5am4tfqH1nKbpqHCid v2FVaYd8W0TxNqsNScfygPqQYjxPzl/1/zkc2SCJssZYgSWGeTqtUtQOZ+Wxyp4Q xaMo9CJ91P2t+uR1zCRIRHWYWI2NlDizIOJGRRXe3KJFRnGZ9j8P0= Received: (qmail 127323 invoked by alias); 21 Jan 2020 21:42:13 -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 127302 invoked by uid 89); 21 Jan 2020 21:42:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Jan 2020 21:42:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579642929; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7PYo/6jsB9hSdGf1s6F32WMVz2K/h9TIxRgeDO+6MXw=; b=B2legXA40TSoo9gUCnlWzaYRokreb6N016QsA8Omhp01b4prBsCP7PfsVAPH46mteYd+C7 8Sna5qa/H1OqPzw/J0h/P9rPbZl/yjy8CmdiPen0lMM6BYElwBXrVnoMcvfqH2uy+oqYzp 9oQdPPrGN/+2Mth32GJwu0gvy2oh+as= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-275-Wqo48bDyNPuc0J0aWB_rLA-1; Tue, 21 Jan 2020 16:42:07 -0500 Received: by mail-qv1-f72.google.com with SMTP id k2so2515555qvu.22 for ; Tue, 21 Jan 2020 13:42:07 -0800 (PST) Received: from barrymore.redhat.com (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id f26sm19590661qtv.77.2020.01.21.13.42.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 13:42:05 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [COMMITTED] PR c++/60855 - ICE with sizeof VLA capture. Date: Tue, 21 Jan 2020 16:42:04 -0500 Message-Id: <20200121214204.7793-1-jason@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes For normal captures we usually look through them within unevaluated context, but that doesn't work here; trying to take the sizeof of the array in the enclosing scope tries and fails to evaluate a SAVE_EXPR from the enclosing scope. Tested x86_64-pc-linux-gnu, applying to trunk. * lambda.c (is_lambda_ignored_entity): Don't look past VLA capture. --- gcc/cp/lambda.c | 5 +++-- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla4.C | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla4.C base-commit: 8158a4640819dbb3210326e37786fb874f450272 diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 50fb144142b..4f39f99756b 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -1327,8 +1327,9 @@ lambda_static_thunk_p (tree fn) bool is_lambda_ignored_entity (tree val) { - /* Look past normal capture proxies. */ - if (is_normal_capture_proxy (val)) + /* Look past normal, non-VLA capture proxies. */ + if (is_normal_capture_proxy (val) + && !variably_modified_type_p (TREE_TYPE (val), NULL_TREE)) return true; /* Always ignore lambda fields, their names are only for debugging. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla4.C new file mode 100644 index 00000000000..3e9cf076d14 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla4.C @@ -0,0 +1,12 @@ +// PR c++/60855 +// { dg-do compile { target c++11 } } +// { dg-additional-options "-Wno-vla" } + +int main() { + unsigned count = 5; + bool array[count]; + [&array] () { + array[0] = sizeof(array) > 5; + }(); + return 0; +}