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.133.124]) by sourceware.org (Postfix) with ESMTPS id 20A00385843E for ; Thu, 9 Mar 2023 23:13:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 20A00385843E 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=1678403586; 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: in-reply-to:in-reply-to:references:references; bh=IF6MfL9QcIH0H5Tyr9/2vNKQ86sxwbmFhAIV1tUfz34=; b=S1bxVYRUApbtIKWuttQnLsB2DYqiuWT+3YRfOCkQmva//AEud+G+NneZKfhBCveIQTwt3V B3FHEJDqXDpFH+wGtrIWrqnqI46wbiT1oVUjLSwR8X1cmTW8CAFwN5w3+FWkoov/45ZJtX dS9il9LqRQDgvcERS90G5SdyztrljGs= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-462-tVOxpkfwMymGk7Fv5frd0w-1; Thu, 09 Mar 2023 18:12:54 -0500 X-MC-Unique: tVOxpkfwMymGk7Fv5frd0w-1 Received: by mail-qt1-f198.google.com with SMTP id t22-20020ac86a16000000b003bd1c0f74cfso1937599qtr.20 for ; Thu, 09 Mar 2023 15:12:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678403574; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IF6MfL9QcIH0H5Tyr9/2vNKQ86sxwbmFhAIV1tUfz34=; b=afnN7YvGTsMt4wqakJNE5DeaY+yOo2xAfiQ9qRc2EtCL6XH6K0b5Sg7SKmOPtRXjMW rtLp72a/OCif9I3Rpvtfrb6VE1TkExCm/oBpS1uqME29b2K7PJAmW2A6RAPJ9NpF1XMB e+Od18FrhfqlOcjIGJmjQlefgA+P1zHLz9fvJtMj7JfE5h5b17Omr1KITLSeTUgzzPW3 wBJyFE9a0BOBYQxbNeJQtlEt/1poswsf3vzOb0F6h/BFHvZ/KqhaTaL3I+IneXN5NQ87 mRNN1f7aZyyBCQU2nHjI5KcEeTR8YEklDMukahVg0/6/ByL7P6FvMlq9z1zPjpPQsfz2 HV0g== X-Gm-Message-State: AO0yUKXYNz9Ggb9PPrB72NRmUf7NTolxQlHhmlIozKYmj2H7gGAW72eS EDSw3vkPGdT+439FD+0MA2/Gx+6Z/oG9e+JtQmofSVD2OPal29+LZ33BIOS3ydhu15zI1juVt7x S87YuXfSfLH9cIQCCkw== X-Received: by 2002:a05:622a:38e:b0:3bb:760d:9345 with SMTP id j14-20020a05622a038e00b003bb760d9345mr32765713qtx.0.1678403573912; Thu, 09 Mar 2023 15:12:53 -0800 (PST) X-Google-Smtp-Source: AK7set8abgiSFhnwPs3Jbwz2Z2Q0cICfIggYqDVLzXMRqNlA0XJXW0eruojH9tbCQ4b1Pr65tlhXWw== X-Received: by 2002:a05:622a:38e:b0:3bb:760d:9345 with SMTP id j14-20020a05622a038e00b003bb760d9345mr32765695qtx.0.1678403573577; Thu, 09 Mar 2023 15:12:53 -0800 (PST) Received: from [192.168.1.108] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id t185-20020ae9dfc2000000b0073b45004754sm187828qkf.34.2023.03.09.15.12.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Mar 2023 15:12:52 -0800 (PST) Message-ID: Date: Thu, 9 Mar 2023 18:12:52 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] c++: noexcept and copy elision [PR109030] To: Patrick Palka , Marek Polacek Cc: GCC Patches References: <20230306235957.390533-1-polacek@redhat.com> <233db53c-67cb-37cf-92ef-620b3678d86f@idea> From: Jason Merrill In-Reply-To: <233db53c-67cb-37cf-92ef-620b3678d86f@idea> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,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 3/9/23 14:32, Patrick Palka wrote: > 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? Sounds good. > 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 >> >> >