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 C6EE23857722 for ; Thu, 7 Sep 2023 07:11:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C6EE23857722 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=1694070708; 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=Tw38+PaakPX8o+VRKs7BRiyFM6RNXWYTOaaqzY1W9BU=; b=QY0SPYZKKEWCSVFdn0KIx0ZqwrJQIxTdIcXuIKgGrVySrfl+TVZ42weJEOzgdQC2HGQZ61 ZfcLH2UIagr5jnME19V8cEt7e+jCsEdXM0pAvnZGshEWubwNdqVm0CD3dJj1da0wrFFNkU FD2QoDc8ekYZJiCbA6LxLQgcETn6Njc= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-612-lxgVz0B2PXWQeEGTTRymjQ-1; Thu, 07 Sep 2023 03:11:47 -0400 X-MC-Unique: lxgVz0B2PXWQeEGTTRymjQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E39A738157B3; Thu, 7 Sep 2023 07:11:46 +0000 (UTC) Received: from localhost (unknown [10.42.28.200]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7ADC400F5F; Thu, 7 Sep 2023 07:11:46 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Simplify C++20 poison pill overloads (P2602R2) Date: Thu, 7 Sep 2023 08:11:42 +0100 Message-ID: <20230907071146.866894-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 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=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: Tested x86_64-linux. Pushed to trunk. -- >8 -- This implements the C++23 change "Poison Pills are Too Toxic". This makes sense to do unconditionally for C++20, as the corner cases that it fixes are considered to be defects in the C++20 design (e.g. LWG3480 was needed to fix directory iterators because of these pills being too toxic). libstdc++-v3/ChangeLog: * include/bits/iterator_concepts.h (__imove::iter_move): Define poison pill as deleted for consistency. (__access::begin): Replace with a single declaration. * include/bits/ranges_base.h (__access::end, __access::rbegin) (__access::rend, __access::size): Likewise. * include/bits/version.def (ranges): Update value for C++23. * include/bits/version.h: Regenerate. * libsupc++/compare (__compare): Add missing poison pill overloads. * testsuite/std/ranges/version_c++23.cc: Adjust expected value of __cpp_lib_ranges. * testsuite/std/ranges/access/p2602.cc: New test. --- libstdc++-v3/include/bits/iterator_concepts.h | 7 ++--- libstdc++-v3/include/bits/ranges_base.h | 14 +++------ libstdc++-v3/include/bits/version.def | 2 +- libstdc++-v3/include/bits/version.h | 4 +-- libstdc++-v3/libsupc++/compare | 6 ++++ .../testsuite/std/ranges/access/p2602.cc | 31 +++++++++++++++++++ .../testsuite/std/ranges/version_c++23.cc | 2 +- 7 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 libstdc++-v3/testsuite/std/ranges/access/p2602.cc diff --git a/libstdc++-v3/include/bits/iterator_concepts.h b/libstdc++-v3/include/bits/iterator_concepts.h index 869d52e378b..3517663db9a 100644 --- a/libstdc++-v3/include/bits/iterator_concepts.h +++ b/libstdc++-v3/include/bits/iterator_concepts.h @@ -100,7 +100,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @cond undocumented namespace __imove { - void iter_move(); + void iter_move() = delete; template concept __adl_imove @@ -979,9 +979,8 @@ namespace ranges { __decay_copy(__t.begin()) } -> input_or_output_iterator; }; - // Poison pills so that unqualified lookup doesn't find std::begin. - void begin(auto&) = delete; - void begin(const auto&) = delete; + // Poison pill so that unqualified lookup doesn't find std::begin. + void begin() = delete; template concept __adl_begin = __class_or_enum> diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h index 35861755c0b..7fa43d1965a 100644 --- a/libstdc++-v3/include/bits/ranges_base.h +++ b/libstdc++-v3/include/bits/ranges_base.h @@ -133,9 +133,8 @@ namespace ranges { __decay_copy(__t.end()) } -> sentinel_for<__range_iter_t<_Tp>>; }; - // Poison pills so that unqualified lookup doesn't find std::end. - void end(auto&) = delete; - void end(const auto&) = delete; + // Poison pill so that unqualified lookup doesn't find std::end. + void end() = delete; template concept __adl_end = __class_or_enum> @@ -184,8 +183,7 @@ namespace ranges { __decay_copy(__t.rbegin()) } -> input_or_output_iterator; }; - void rbegin(auto&) = delete; - void rbegin(const auto&) = delete; + void rbegin() = delete; template concept __adl_rbegin = __class_or_enum> @@ -248,8 +246,7 @@ namespace ranges -> sentinel_for(__t)))>; }; - void rend(auto&) = delete; - void rend(const auto&) = delete; + void rend() = delete; template concept __adl_rend = __class_or_enum> @@ -306,8 +303,7 @@ namespace ranges { __decay_copy(__t.size()) } -> __detail::__is_integer_like; }; - void size(auto&) = delete; - void size(const auto&) = delete; + void size() = delete; template concept __adl_size = __class_or_enum> diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index 44b916e3897..da8d067dd1a 100644 --- a/libstdc++-v3/include/bits/version.def +++ b/libstdc++-v3/include/bits/version.def @@ -1045,7 +1045,7 @@ ftms = { ftms = { name = ranges; values = { - v = 202207; + v = 202211; cxxmin = 23; extra_cond = "__glibcxx_concepts"; }; diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h index 9fada98eee3..22cc21119c5 100644 --- a/libstdc++-v3/include/bits/version.h +++ b/libstdc++-v3/include/bits/version.h @@ -1290,9 +1290,9 @@ // from version.def line 1046 #if !defined(__cpp_lib_ranges) # if (__cplusplus >= 202302L) && (__glibcxx_concepts) -# define __glibcxx_ranges 202207L +# define __glibcxx_ranges 202211L # if defined(__glibcxx_want_all) || defined(__glibcxx_want_ranges) -# define __cpp_lib_ranges 202207L +# define __cpp_lib_ranges 202211L # endif # elif (__cplusplus >= 202002L) && (__glibcxx_concepts) # define __glibcxx_ranges 202110L diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare index 84ef31a1ee7..51693794491 100644 --- a/libstdc++-v3/libsupc++/compare +++ b/libstdc++-v3/libsupc++/compare @@ -612,6 +612,8 @@ namespace std _GLIBCXX_VISIBILITY(default) } } + void strong_order() = delete; + template concept __adl_strong = requires(_Tp&& __t, _Up&& __u) { @@ -619,6 +621,8 @@ namespace std _GLIBCXX_VISIBILITY(default) static_cast<_Up&&>(__u))); }; + void weak_order() = delete; + template concept __adl_weak = requires(_Tp&& __t, _Up&& __u) { @@ -626,6 +630,8 @@ namespace std _GLIBCXX_VISIBILITY(default) static_cast<_Up&&>(__u))); }; + void partial_order() = delete; + template concept __adl_partial = requires(_Tp&& __t, _Up&& __u) { diff --git a/libstdc++-v3/testsuite/std/ranges/access/p2602.cc b/libstdc++-v3/testsuite/std/ranges/access/p2602.cc new file mode 100644 index 00000000000..9c6a0e6ee95 --- /dev/null +++ b/libstdc++-v3/testsuite/std/ranges/access/p2602.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++20" } +// { dg-do compile { target c++20 } } + +// P2602R2 Poison Pills are Too Toxic + +#include + +struct A { + friend auto begin(A const&) -> int const*; + friend auto end(A const&) -> int const*; +}; + +struct B { + friend auto begin(B&) -> int*; + friend auto end(B&) -> int*; +}; + +static_assert( std::ranges::range ); +static_assert( std::ranges::range ); +static_assert( std::ranges::range ); +static_assert( ! std::ranges::range ); + +class Test { + friend size_t size(const Test&) { + return 0; + } +}; + +size_t f(Test t) { + return std::ranges::size(t); +} diff --git a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc index 8e4a8b466aa..64b7df409c9 100644 --- a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc +++ b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc @@ -4,7 +4,7 @@ #include #if __STDC_HOSTED__ -# if __cpp_lib_ranges != 202207L +# if __cpp_lib_ranges != 202211L # error "Feature-test macro __cpp_lib_ranges has wrong value in " # endif #endif -- 2.41.0