From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 887253858D20 for ; Thu, 9 Mar 2023 19:32:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 887253858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678390375; 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: in-reply-to:in-reply-to:references:references; bh=ycltq9sxB8+biD/jJSJ4GpLRUHmGtVrWApz1U40q5tE=; b=NCNeuMPGHpW/txZp3Btj59x6RqYLbYaFp5doYJopzfiva3O1cA6Z0qCmy1E4nZHEsMBvMh 2SziYPw2Q8ixz0xkOgJi3cgW0ORuGSBQk+uXduL2e26BMAHX2L8YJGcwflWMLpuW1xYZkv +6ovsvtpaP5KK1d3PhJD/3gdtLxPfog= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-157-Lt3Oiln6MjKTxaM3tvbpvg-1; Thu, 09 Mar 2023 14:32:44 -0500 X-MC-Unique: Lt3Oiln6MjKTxaM3tvbpvg-1 Received: by mail-qv1-f70.google.com with SMTP id pm17-20020ad446d1000000b0057256b237b9so1748677qvb.16 for ; Thu, 09 Mar 2023 11:32:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678390364; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ycltq9sxB8+biD/jJSJ4GpLRUHmGtVrWApz1U40q5tE=; b=J03b1U6V38fQtfRWdEeGx6JGXXpVOEOqwb8mlqkuct+oTjfe8imlQXtxbzAEqqlYav Ov7NcITYwJWRuJKH+7DiiWBpPlMQOzj5felpfmrZHUxTYnc2bvawRsXod9QwgIX40u2o V+pkDp1ZDEsN7kZRREfVpSxZLv2gQy6wcninWxjIPwKi6Ze9dy9lQ6nYG+iE906FC413 Bh25FI/heZPqwYDV0epO4L68R+WjX6QfnImCMa/FGDi4BCGbSZriNBKMlSScnC6TyXnl yQcU/vyVeqjJASnD2uFleuXf2HZWjAoh5PXzlKAvpQBmQ8W5Cr57fIkkhcYpTmdeEQR8 SmRw== X-Gm-Message-State: AO0yUKVwUKuYI5we05qtkxnVTbsZFqi4Aq7UAImREDWqbMDPYb9yrvBI RuW0rx//zRyHf41hMoSgfQwQmPaklayzBCkL2ouWfbezZdcBLg1P8nxwelCmLWw88I2yt4FhtC5 eZWHZPcwNf2DTHDKu/Q== X-Received: by 2002:a05:622a:1992:b0:3bf:e408:6c91 with SMTP id u18-20020a05622a199200b003bfe4086c91mr41133504qtc.51.1678390363978; Thu, 09 Mar 2023 11:32:43 -0800 (PST) X-Google-Smtp-Source: AK7set+rl/2PJE4LSD6id08oMurOv3Qlr9VyXE9MzR/2zJwlXo7yE1Agg43ZnnK0LN/GE2VDcPFzsQ== X-Received: by 2002:a05:622a:1992:b0:3bf:e408:6c91 with SMTP id u18-20020a05622a199200b003bfe4086c91mr41133482qtc.51.1678390363677; Thu, 09 Mar 2023 11:32:43 -0800 (PST) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id d79-20020ae9ef52000000b007296805f607sm14111841qkg.17.2023.03.09.11.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 11:32:43 -0800 (PST) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Thu, 9 Mar 2023 14:32:41 -0500 (EST) To: Marek Polacek cc: GCC Patches , Jason Merrill Subject: Re: [PATCH] c++: noexcept and copy elision [PR109030] In-Reply-To: <20230306235957.390533-1-polacek@redhat.com> Message-ID: <233db53c-67cb-37cf-92ef-620b3678d86f@idea> References: <20230306235957.390533-1-polacek@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-13.9 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_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, 6 Mar 2023, Marek Polacek via Gcc-patches wrote: > When processing a noexcept, constructors aren't elided: build_over_call > has > /* It's unsafe to elide the constructor when handling > a noexcept-expression, it may evaluate to the wrong > value (c++/53025). */ > && (force_elide || cp_noexcept_operand == 0)) > so the assert I added recently needs to be relaxed a little bit. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > PR c++/109030 > > gcc/cp/ChangeLog: > > * constexpr.cc (cxx_eval_call_expression): Relax assert. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp0x/noexcept77.C: New test. > --- > gcc/cp/constexpr.cc | 6 +++++- > gcc/testsuite/g++.dg/cpp0x/noexcept77.C | 9 +++++++++ > 2 files changed, 14 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept77.C > > diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc > index 364695b762c..5384d0e8e46 100644 > --- a/gcc/cp/constexpr.cc > +++ b/gcc/cp/constexpr.cc > @@ -2869,7 +2869,11 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, > > /* We used to shortcut trivial constructor/op= here, but nowadays > we can only get a trivial function here with -fno-elide-constructors. */ > - gcc_checking_assert (!trivial_fn_p (fun) || !flag_elide_constructors); > + gcc_checking_assert (!trivial_fn_p (fun) > + || !flag_elide_constructors > + /* We don't elide constructors when processing > + a noexcept-expression. */ > + || cp_noexcept_operand); It seems weird that we're performing constant evaluation within an unevaluated operand. Would it make sense to also fix this a second way by avoiding constant evaluation from maybe_constant_init when cp_unevaluated_operand && !manifestly_const_eval, like in maybe_constant_value? IIUC since we could still have an evaluated subexpression withis noexcept, the two fixes would be complementary. > > bool non_constant_args = false; > new_call.bindings > diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept77.C b/gcc/testsuite/g++.dg/cpp0x/noexcept77.C > new file mode 100644 > index 00000000000..16db8eb79ee > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept77.C > @@ -0,0 +1,9 @@ > +// PR c++/109030 > +// { dg-do compile { target c++11 } } > + > +struct foo { }; > + > +struct __as_receiver { > + foo empty_env; > +}; > +void sched(foo __fun) noexcept(noexcept(__as_receiver{__fun})) { } > > base-commit: dfb14cdd796ad9df6b5f2def047ef36b29385902 > -- > 2.39.2 > >