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 9C4D03858D37 for ; Thu, 3 Feb 2022 21:38:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9C4D03858D37 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-313-tAbElekFOCqkdsARieNtBQ-1; Thu, 03 Feb 2022 16:38:55 -0500 X-MC-Unique: tAbElekFOCqkdsARieNtBQ-1 Received: by mail-qt1-f199.google.com with SMTP id g18-20020ac84b72000000b002cf274754c5so3182653qts.14 for ; Thu, 03 Feb 2022 13:38:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=R5rBHAWSkvn91TPnciQlE7dtBbXBgQkbOfVFzICOhtw=; b=1qaUm6z1/xERifbwBnFJEkpxEORkqljkqwll3qXcpVIYciT1JvGoT3VFnThF1uj1oj CU3L7pTjvdJ1ygTpftId+7Pk8tmIYMaDOAJ8skGKU/qIcsWiquQ7V64TDA+zz846YPup srqUGaIw1reJpH6mhB8ZqRhNI5KcgrIWF4NCJD49RnNYIkRY5OQ7NthVCFl5FS/JyjJv vw313jDlp83G+OX6DvEMvpYDsoFzWqD6Z5PImxjFmIQK+xlsqFFmBqjqaC1mgWzRzvws wBHr6qMi0b+rneXkquGaYDKtneF6+UXZqHfX1xrnFrcNU/IK8h7AJHsTnxT/PM6Xs+3B pBPQ== X-Gm-Message-State: AOAM532GO7d0wYkpTDnwPWBtbhZgHY8uriJlRpj/EWRzsUzme4yXEySn bjQ4hQtp0NzQrArLb4bNAWVmdcYxHQjiuBq/FHoQJrQ0N3ZUOZpRiqtQteqNj7s4Vb5pNSTuaH0 9d8G95CquMbzvkM4kFA== X-Received: by 2002:a05:6214:c47:: with SMTP id r7mr13467381qvj.6.1643924334767; Thu, 03 Feb 2022 13:38:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGr8yXzI6RZQnULx6dr6gzw9Yua0jOVxuhNrGZ4sBNgMj0DubeEi9KxQv8DlnV/YkI5XOMPA== X-Received: by 2002:a05:6214:c47:: with SMTP id r7mr13467370qvj.6.1643924334501; Thu, 03 Feb 2022 13:38:54 -0800 (PST) Received: from [192.168.1.149] (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 o13sm65788qtx.22.2022.02.03.13.38.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Feb 2022 13:38:53 -0800 (PST) Message-ID: Date: Thu, 3 Feb 2022 16:38:52 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH] c++: conditional noexcept-spec on defaulted comparison op [PR96242] To: Patrick Palka Cc: gcc-patches@gcc.gnu.org References: <20220203195838.409426-1-ppalka@redhat.com> <152576a5-c950-b21c-edfd-a15a7b0305b3@redhat.com> <6f99b484-a501-ba99-ffd1-d124c6c48a72@idea> From: Jason Merrill In-Reply-To: <6f99b484-a501-ba99-ffd1-d124c6c48a72@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.9 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_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Thu, 03 Feb 2022 21:38:58 -0000 On 2/3/22 16:06, Patrick Palka wrote: > On Thu, 3 Feb 2022, Jason Merrill wrote: > >> On 2/3/22 14:58, Patrick Palka wrote: >>> When synthesizing a defaulted comparison op from >>> maybe_instantiate_noexcept, we seem to be forgetting to instantiate the >>> noexcept-spec afterwards. >> >> Hmm, there shouldn't be any need to instantiate the noexcept-spec afterwards, >> it should have been set by ~comp_info. > > It appears the comp_info class sets the noexcept-spec only if the > comparison function hasn't been declared with an explicit noexcept-spec. > Otherwise the class doesn't touch the noexcept-spec, and it remains a > DEFERRED_NOEXCEPT with non-NULL DEFERRED_NOEXCEPT_PATTERN. Ah, I see. So perhaps we should entirely skip the current DECL_MAYBE_DELETED handling in maybe_instantiate_noexcept if we have DEFERRED_NOEXCEPT with non-null DEFERRED_NOEXCEPT_PATTERN (which seems to want another macro)? >>> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for >>> trunk and perhaps 11? >>> >>> PR c++/96242 >>> >>> gcc/cp/ChangeLog: >>> >>> * pt.cc (maybe_instantiate_noexcept): Keep going after >>> successfully synthesizing a DECL_MAYBE_DELETED fn. >>> >>> gcc/testsuite/ChangeLog: >>> >>> * g++.dg/cpp2a/spaceship-synth15.C: New test. >>> --- >>> gcc/cp/pt.cc | 3 ++- >>> .../g++.dg/cpp2a/spaceship-synth15.C | 22 +++++++++++++++++++ >>> 2 files changed, 24 insertions(+), 1 deletion(-) >>> create mode 100644 gcc/testsuite/g++.dg/cpp2a/spaceship-synth15.C >>> >>> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc >>> index 6dd64101ced..03345ed3ed3 100644 >>> --- a/gcc/cp/pt.cc >>> +++ b/gcc/cp/pt.cc >>> @@ -25986,7 +25986,8 @@ maybe_instantiate_noexcept (tree fn, tsubst_flags_t >>> complain) >>> ++function_depth; >>> maybe_synthesize_method (fn); >>> --function_depth; >>> - return !DECL_MAYBE_DELETED (fn); >>> + if (DECL_MAYBE_DELETED (fn)) >>> + return false; >>> } >>> tree fntype = TREE_TYPE (fn); >>> diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-synth15.C >>> b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth15.C >>> new file mode 100644 >>> index 00000000000..00ea6c10474 >>> --- /dev/null >>> +++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth15.C >>> @@ -0,0 +1,22 @@ >>> +// PR c++/96242 >>> +// { dg-do compile { target c++20 } } >>> + >>> +#include >>> + >>> +template >>> +struct X { >>> + auto operator<=>(const X&) const noexcept(B) = default; >>> + bool operator==(const X&) const noexcept(!B) = default; >>> +}; >>> + >>> +X x_t; >>> +static_assert(noexcept(x_t <=> x_t)); >>> +static_assert(noexcept(x_t < x_t)); >>> +static_assert(!noexcept(x_t == x_t)); >>> +static_assert(!noexcept(x_t != x_t)); >>> + >>> +X x_f; >>> +static_assert(!noexcept(x_f <=> x_f)); >>> +static_assert(!noexcept(x_f < x_f)); >>> +static_assert(noexcept(x_f == x_f)); >>> +static_assert(noexcept(x_f != x_f)); >> >> >