aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Kamiński <tkaminsk@redhat.com>2025-08-28 15:48:03 +0200
committerTomasz Kamiński <tkaminsk@redhat.com>2025-08-28 15:57:06 +0200
commitf4b96998f1c1aa22c70462d018f8a3d4a8ec214a (patch)
tree073d9574fd835c4dececfdf1df83edabb879353f
parent2649c79496a47109b9821d9db7f69aa94e8d3f04 (diff)
downloadgcc-f4b96998f1c1aa22c70462d018f8a3d4a8ec214a.zip
gcc-f4b96998f1c1aa22c70462d018f8a3d4a8ec214a.tar.gz
gcc-f4b96998f1c1aa22c70462d018f8a3d4a8ec214a.tar.bz2
libstdc++: Test comparing ordering with type convertible to any pointer.
libstdc++-v3/ChangeLog: * testsuite/18_support/comparisons/categories/zero_neg.cc: New test. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
-rw-r--r--libstdc++-v3/testsuite/18_support/comparisons/categories/zero_neg.cc16
1 files changed, 16 insertions, 0 deletions
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 2e6b9c1..ce0ca8e 100644
--- a/libstdc++-v3/testsuite/18_support/comparisons/categories/zero_neg.cc
+++ b/libstdc++-v3/testsuite/18_support/comparisons/categories/zero_neg.cc
@@ -23,6 +23,16 @@
// C++20 [cmp.categories.pre]
// "an argument other than a literal 0 is undefined"
+struct PtrConv
+{
+ template<typename T>
+ consteval operator T*()
+ { return nullptr; }
+
+ consteval operator std::nullptr_t()
+ { return nullptr; }
+};
+
void
test01()
{
@@ -48,6 +58,12 @@ test01()
std::partial_ordering::equivalent == nullptr;
std::weak_ordering::equivalent == nullptr;
std::strong_ordering::equivalent == nullptr;
+
+ constexpr PtrConv c;
+ // requires two user-defined conversion
+ std::partial_ordering::equivalent == c; // { dg-error "no match for 'operator=='" }
+ std::weak_ordering::equivalent == c; // { dg-error "no match for 'operator=='" }
+ std::strong_ordering::equivalent == c; // { dg-error "no match for 'operator=='" }
}
// { dg-prune-output "reinterpret_cast.* is not a constant expression" }