From patchwork Fri May 1 17:57:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1281409 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=wL5WTBBy; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49DKhf4Qndz9sP7 for ; Sat, 2 May 2020 03:57:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 05D25397306E; Fri, 1 May 2020 17:57:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05D25397306E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588355837; bh=XJTYTL+6n66vMPGxncsuulX89E9YmJqrEwnSIcmlDog=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=wL5WTBByLGDkdf9nyoSeC5xsbj3B1dMG4joW1jOu+UB1gOaBC0rLsKC+K8I90Rzyy 6vSn8BQsEbJfXxtl1VQDVYaSfclomSruJ7XkKqQ2hwO0EUK2Wyji1igqt7XYxo6tQj +8TH5vMyk2vlWylNXUeIyupLFiNR6IjiVT3IfFnU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id C9F4D3938C06 for ; Fri, 1 May 2020 17:57:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C9F4D3938C06 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-R7PInSwSO9OVQ3_XNndUlQ-1; Fri, 01 May 2020 13:57:12 -0400 X-MC-Unique: R7PInSwSO9OVQ3_XNndUlQ-1 Received: by mail-qv1-f69.google.com with SMTP id x26so10777746qvd.20 for ; Fri, 01 May 2020 10:57:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=pPHli+GGJV8WAyzSkFK4Khx8EwPEmo51fLV65BD7Mno=; b=cQuiMNWRW1C54tvm6WTAR+Qpr+VDDh6e7y2gv6C7rMD151EK+ojBchKN1uyyz44ZEr qp7yzDb160/JMPGf7ZQB2mARyusEmppGpY77556Tt+XGnhnPKOG3+2tAcfu2k3OKK/Wx BP0fykBU+NYLSlfKnnxLTqswIJYVyP4e9sImhe18g3DLHhOkbFph5WaoHgoTQ+5hcZrD I5AX5rJKiXVCksLTVYCpu8VF8R5PbD0KowA++nq/byc033FrWOwUc5DpcTZj1VjVz42F H5QlKaIV/QioTBz2dp2OceLA3nvhXOObY2IV4WF4ksutqOG6kByg8kh98XYtqtdFZhTy 0OfQ== X-Gm-Message-State: AGi0PuaYKYi+gSzhyakLGMgUgjrpzw5Rc4H5ybDiiOCyG1pHQQ+JSlmU UTcW9y5FYiqyKbLvD86ZoCqTpefieonSyWbHpqrdmIfHVgDacg9mS8UrTbYDW2YonGprmF/9bN1 3/QJ1mhYw5Yk4gQsZ7g== X-Received: by 2002:a37:6296:: with SMTP id w144mr4772758qkb.310.1588355832180; Fri, 01 May 2020 10:57:12 -0700 (PDT) X-Google-Smtp-Source: APiQypLOmMXW8xxkmFIR4TVA+7cWEEHL0kbbU8kvBYlquN0fKASWY5DjA8MxlQcBAiRHwkZiGe+/uQ== X-Received: by 2002:a37:6296:: with SMTP id w144mr4772731qkb.310.1588355831806; Fri, 01 May 2020 10:57:11 -0700 (PDT) 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 103sm3039821qte.82.2020.05.01.10.57.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:57:11 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: generic lambda and -fsanitize=vla-bound [PR93822] Date: Fri, 1 May 2020 13:57:07 -0400 Message-Id: <20200501175707.7958-1-jason@redhat.com> X-Mailer: git-send-email 2.18.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-28.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Within the generic lambda the VLA capture proxy VAR_DECL has DECL_VALUE_EXPR which is a NOP_EXPR to the VLA type of the proxy. The problem here was that when instantiating we were tsubsting that type twice, once for the type of the DECL and once for the type of the NOP_EXPR, and getting two different (though equivalent) types. Then gimplify_type_sizes fixed up the type of the DECL, but that didn't affect the type of the NOP_EXPR, leading to sadness. Fixed by directly reusing the type from the DECL. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog 2020-05-01 Jason Merrill PR c++/93822 * pt.c (tsubst_decl): Make sure DECL_VALUE_EXPR continues to have the same type as the variable. --- gcc/cp/pt.c | 9 +++++++++ 1 file changed, 9 insertions(+) base-commit: afb9b7108104a73e8ac7a9b8e6875870e5ca4bbb diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d28585efd17..9332865cf46 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14609,6 +14609,11 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) if (DECL_HAS_VALUE_EXPR_P (t)) { tree ve = DECL_VALUE_EXPR (t); + /* If the DECL_VALUE_EXPR is converted to the declared type, + preserve the identity so that gimplify_type_sizes works. */ + bool nop = (TREE_CODE (ve) == NOP_EXPR); + if (nop) + ve = TREE_OPERAND (ve, 0); ve = tsubst_expr (ve, args, complain, in_decl, /*constant_expression_p=*/false); if (REFERENCE_REF_P (ve)) @@ -14616,6 +14621,10 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) gcc_assert (TYPE_REF_P (type)); ve = TREE_OPERAND (ve, 0); } + if (nop) + ve = build_nop (type, ve); + else + gcc_checking_assert (TREE_TYPE (ve) == type); SET_DECL_VALUE_EXPR (r, ve); } if (CP_DECL_THREAD_LOCAL_P (r)