From patchwork Mon Jan 8 18:40:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 83554 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 90D31385840F for ; Mon, 8 Jan 2024 18:40:47 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A3C5C3858424 for ; Mon, 8 Jan 2024 18:40:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A3C5C3858424 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A3C5C3858424 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704739219; cv=none; b=NSnLlvgNmxp51JbsScmqURa7yyofD2UN3BVZ8h9Z39MuiSGBWtj14mTG7txIytYtf0MeYfg6t/o8lbVbTjsK8FI1TKjLvm8vF/G3RAnTXI0gXpFZmZRnQlAC+MbztCrLEMolh/ElwrWUFnV8XYVCVI8m3nmC6jDvPcviWI2LO2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704739219; c=relaxed/simple; bh=/dZ48OrMTvb6+3dCYrDottPvADJU3PlKZt1uyY7Z/i8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=W6nmipkkDDvEAbU6sbSHZZrbMxwkaSrL4RMhj76oJyetAqU2hGFsgSCUBnkuFQu44fzTDCI+wZA8jP467W4+uuRvZ9M2PIWJjO1EDDG97FqnoyhiIOQc5FcgCQHh7UJjw7sO3Ei7tIZuvn6QSfNKRs+l3Bu7BzcelzIp5OT1gIQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704739217; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=laCVNRysluZqL6lBdqLEVrfGs7vn/P1Wz+A4dNIC0ds=; b=fRZ5dBTn/naxX1shXUo8D4Rum2SAqZtm7BCXWMqNV1rGUBR5zhPiExzf5sDnv0RRvD/fDR yK7RzecpV6aT4DGSiPQ0ALfmR1Ucu2uEdKwXCmHlDbQbwIQf2ehHgSGrFWmiABF+c6Pfky fYPUzavaFJNZez+EotXXECj01K+MvC0= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-A7Tkcd5_PCyMzA69-XXG7g-1; Mon, 08 Jan 2024 13:40:16 -0500 X-MC-Unique: A7Tkcd5_PCyMzA69-XXG7g-1 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3bb7ab55483so3025776b6e.1 for ; Mon, 08 Jan 2024 10:40:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704739214; x=1705344014; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=laCVNRysluZqL6lBdqLEVrfGs7vn/P1Wz+A4dNIC0ds=; b=p76a6W/SXP54VakD7jqkpqemzfgq6n2aLN0TlzaC2S1PI1p6gHKOr9Js7tawCjmcuW kWTJK4haVwx9FqpyvIKGTD3/jAihyZfVTY2Oz3CJc56noRrWuPb6mC7Bk5/31IPzx0Qn pcSAUZcGd3va49pgiP2KIWswozuSJPwKWsgAYfysNNLtjyg8zaMxx++LTPIpwRPDxlTu qndbbULKLWVsnv17E4oDWb+6zmkw+4LeDeP2k+ROobNTpZScPPclNaHq3HxUM45R7chv fmpQQPpAWZo4Iu/8AptYr+lALlXq+pxItbyc+0VcsoJf+vfrfz04joII4I4zLtawOp7k 9JWw== X-Gm-Message-State: AOJu0YzGyh6Eh1m+v2I6qvQhaM0bkzMhHWEgmg8wE/OYSDHizAytA+n5 ICyeFpgC4K74hp35NP8JIKM1UE2OTFDCIt5PU13/63lokyzwdA6amDZ8oz9HGZhxVvOHGT3nvA+ y6nVAAdaKJoEI+BBkXBwr4F7yhene/txPiSTBdkIeLCU58gGuCNwK55yNNfFlwg/rrLO4bQvAtA LxDRj0RqM= X-Received: by 2002:a05:6358:2799:b0:174:f06b:333d with SMTP id l25-20020a056358279900b00174f06b333dmr5821650rwb.41.1704739213843; Mon, 08 Jan 2024 10:40:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6ww6jbkgkrvkEHRpFm6KZAEIM5yI8Z3vS0DvShaOkvOvEGC2M2xF7DO1WCYq7fcMi5jhDWQ== X-Received: by 2002:a05:6358:2799:b0:174:f06b:333d with SMTP id l25-20020a056358279900b00174f06b333dmr5821637rwb.41.1704739213433; Mon, 08 Jan 2024 10:40:13 -0800 (PST) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id dn7-20020a05622a470700b0042993549c3asm118959qtb.32.2024.01.08.10.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 10:40:13 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: non-dep array list-init w/ non-triv dtor [PR109899] Date: Mon, 8 Jan 2024 13:40:10 -0500 Message-ID: <20240108184010.2235409-1-ppalka@redhat.com> X-Mailer: git-send-email 2.43.0.254.ga26002b628 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk/13/12? -- >8 -- The get_target_expr call added in r12-7069-g119cea98f66476 causes us for the below testcase to call build_vec_delete in a template context, which builds a templated destructor call and checks expr_noexcept_p for it, which ICEs because the call has templated form. Much of the work of build_vec_delete however is code generation and thus will just get throw away in a template context, including this expr_noexcept_p check and the code generation guarded by it. So this patch narrowly fixes this ICE by assuming the expr_noexcept_p call returns true in a template context. PR c++/109899 gcc/cp/ChangeLog: * init.cc (build_vec_delete_1): Assume expr_noexcept_p is true in a template context. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/initlist-array21.C: New test. --- gcc/cp/init.cc | 3 ++- gcc/testsuite/g++.dg/cpp0x/initlist-array21.C | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-array21.C diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index 09584719ee6..aa0a35a3885 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -4155,7 +4155,8 @@ build_vec_delete_1 (location_t loc, tree base, tree maxindex, tree type, /* If one destructor throws, keep trying to clean up the rest, unless we're already in a build_vec_init cleanup. */ - if (flag_exceptions && !in_cleanup && !expr_noexcept_p (tmp, tf_none)) + if (flag_exceptions && !in_cleanup && !processing_template_decl + && !expr_noexcept_p (tmp, tf_none)) { loop = build2 (TRY_CATCH_EXPR, void_type_node, loop, unshare_expr (loop)); diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array21.C b/gcc/testsuite/g++.dg/cpp0x/initlist-array21.C new file mode 100644 index 00000000000..5e37e3de62a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-array21.C @@ -0,0 +1,12 @@ +// PR c++/109899 +// { dg-do compile { target c++11 } } + +struct A { A(); ~A(); }; + +template +using array = T[42]; + +template +void f() { + array{}; +}