Message ID | 20240108184010.2235409-1-ppalka@redhat.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp1205853dyq; Mon, 8 Jan 2024 10:41:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBn3sR7cwm9fTLZDP8eqqldXcX0cr/JcX867hBeKq5xdKYU1FuigfORfDVH7m/4lnXUQ1o X-Received: by 2002:a05:6870:5254:b0:203:337:3f12 with SMTP id o20-20020a056870525400b0020303373f12mr4805055oai.71.1704739264281; Mon, 08 Jan 2024 10:41:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704739264; cv=pass; d=google.com; s=arc-20160816; b=pKXonx1ab7Fppo+vJjHd8BpTB6CXL24wX72ERTyMYqa62HEF8gW+Z4puwdgZXlG+V+ qtR3XmIvjl4M/MaWnLWivrI63UgAu8z7CWGJ0Xl5QAzz48lNfWGBnuOD9a6UadbXMpDm ZR8TsKU1ZVg+zKOzn7AXmA6cHmT4eG9664BBH7nPssOmKsG3Y687nW9LOudU4skeB4z9 haXkjeOh78h6ufmFdNKs863RETa6t3LdzHL0Bwjq1b7z2J3vBCEimK/6yBvFTXuxPijR d9qrR04q1b9IDqSCX1y0oabGgvgTxF5qc71qYJ18yfBmKjs8qxhfv0gXHRRzYwFSfW+/ JSSA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=laCVNRysluZqL6lBdqLEVrfGs7vn/P1Wz+A4dNIC0ds=; fh=1Hi9m88IqcWZGtfSxUrMGG+GBgL26N02X1SANXM6iTs=; b=eli6JcwniamJ0sFqmGzRn3/+NvX0BDhrc2Vwk4y8Pqd+FVIHgxSQb7oaAWkgi3CMv/ BY72rVDbTiJHzMShJLWFnN4jnKC0/i/k08c6OR+osmkN9Y032Onp6U9HhMs4j3piAP2Z 0O4bE0/JAdQdvI3xEMQQqdbFovCYJJF/RgKFp8l02PbMg67N87xco74Pt/ZxVSyJn+zj I4j/praVWVxUGfQPPC6PAx4uot2nHEpiWnG/pCm49OhqbRm+AaaYG2Im2V/Q3KfAzuGA vLYooxirV++wKN5Z/zgF+Vkz/bIFhiIMnqw758j0GE6/dbOpLC3MoxOm2ivyWyqyx4Ch DsLw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fRZ5dBTn; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id y25-20020a05620a0e1900b007815efd950csi252236qkm.439.2024.01.08.10.41.04 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 10:41:04 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fRZ5dBTn; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F8EE385828F for <ouuuleilei@gmail.com>; Mon, 8 Jan 2024 18:41:03 +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 <gcc-patches@gcc.gnu.org>; 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 <gcc-patches@gcc.gnu.org>; 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-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 <ppalka@redhat.com> To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka <ppalka@redhat.com> 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787548678640578672 X-GMAIL-MSGID: 1787548678640578672 |
Series |
c++: non-dep array list-init w/ non-triv dtor [PR109899]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Patrick Palka
Jan. 8, 2024, 6:40 p.m. UTC
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
Comments
On Mon, Jan 8, 2024 at 1:40 PM Patrick Palka <ppalka@redhat.com> wrote: > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look > OK for trunk/13/12? Ping. > > -- >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 ... returns false, rather. > context. > > PR c++/109899 > > gcc/cp/ChangeLog: > > * init.cc (build_vec_delete_1): Assume expr_noexcept_p is true .. is false. > 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 <typename T> > +using array = T[42]; > + > +template<class T> > +void f() { > + array<A>{}; > +} > -- > 2.43.0.254.ga26002b628 >
On 1/8/24 13:40, Patrick Palka wrote: > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look > OK for trunk/13/12? OK. > -- >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 <typename T> > +using array = T[42]; > + > +template<class T> > +void f() { > + array<A>{}; > +}
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 <typename T> +using array = T[42]; + +template<class T> +void f() { + array<A>{}; +}