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 963E138768A0 for ; Thu, 17 Aug 2023 20:31:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 963E138768A0 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=1692304315; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3SCjuXi/5wAsq/QR4kWMO1C/s13hXgV5tQtcuqZ2FdQ=; b=Z9AZpH+5BbcbdD6dtYTnmBsO6SpgUMYDoacZYb21S8KE2PdujJMbFOyEoDkL0K3YHrUz/J QRuwdNrY2ICC08NkQZYYfPuoZuK01rGXCbQizLJOAegC9sTUPdCoFhf/Umm+HTOnoE+Umh PKUisV7wIOJl2Flu0rosytNB5Xs0n2U= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-19-up2M_7zLOjyDqPPqwQTLig-1; Thu, 17 Aug 2023 16:31:52 -0400 X-MC-Unique: up2M_7zLOjyDqPPqwQTLig-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E03378DC66E; Thu, 17 Aug 2023 20:31:51 +0000 (UTC) Received: from localhost (unknown [10.42.28.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAE42492C13; Thu, 17 Aug 2023 20:31:51 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Make __cmp_cat::__unseq constructor consteval Date: Thu, 17 Aug 2023 21:31:37 +0100 Message-ID: <20230817203151.1131407-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.8 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_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-linux. Pushed to trunk. Probably good to backport. -- >8 -- This constructor should only ever be used with a literal 0 as the argument, so we can make it consteval. This has the nice advantage that it is expanded immediately in the front end, and so GDB will never step into the __cmp_cat::__unseq::__unseq(__unseq*) constructor that is uninteresting and probably confusing to users. libstdc++-v3/ChangeLog: * libsupc++/compare (__cmp_cat::__unseq): Make ctor consteval. * testsuite/18_support/comparisons/categories/zero_neg.cc: Prune excess errors caused by invalid consteval calls. --- libstdc++-v3/libsupc++/compare | 2 +- .../18_support/comparisons/categories/zero_neg.cc | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare index b133fdbcf1e..9215f51e94b 100644 --- a/libstdc++-v3/libsupc++/compare +++ b/libstdc++-v3/libsupc++/compare @@ -53,7 +53,7 @@ namespace std _GLIBCXX_VISIBILITY(default) struct __unspec { - constexpr __unspec(__unspec*) noexcept { } + consteval __unspec(__unspec*) noexcept { } }; } diff --git a/libstdc++-v3/testsuite/18_support/comparisons/categories/zero_neg.cc b/libstdc++-v3/testsuite/18_support/comparisons/categories/zero_neg.cc index 7daf799f71d..17a129bcb75 100644 --- a/libstdc++-v3/testsuite/18_support/comparisons/categories/zero_neg.cc +++ b/libstdc++-v3/testsuite/18_support/comparisons/categories/zero_neg.cc @@ -34,6 +34,11 @@ test01() std::weak_ordering::equivalent == 1; // { dg-error "invalid conversion" } std::strong_ordering::equivalent == 1; // { dg-error "invalid conversion" } + constexpr int z = 0; + std::partial_ordering::equivalent == z; // { dg-error "invalid conversion" } + std::weak_ordering::equivalent == z; // { dg-error "invalid conversion" } + std::strong_ordering::equivalent == z; // { dg-error "invalid conversion" } + constexpr void* p = nullptr; std::partial_ordering::equivalent == p; // { dg-error "invalid conversion" } std::weak_ordering::equivalent == p; // { dg-error "invalid conversion" } @@ -44,3 +49,6 @@ test01() std::weak_ordering::equivalent == nullptr; std::strong_ordering::equivalent == nullptr; } + +// { dg-prune-output "reinterpret_cast.* is not a constant expression" } +// { dg-prune-output "cast from 'void.' is not allowed" } -- 2.41.0