]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Test comparing ordering with type convertible to any pointer.
authorTomasz Kamiński <tkaminsk@redhat.com>
Thu, 28 Aug 2025 13:48:03 +0000 (15:48 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Thu, 28 Aug 2025 13:57:06 +0000 (15:57 +0200)
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>
libstdc++-v3/testsuite/18_support/comparisons/categories/zero_neg.cc

index 2e6b9c14ddbec2ed7247f6d2ca37c92ec969e727..ce0ca8efa6f594bbc4858cf1717a863b1380a5e6 100644 (file)
 // 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" }