[libcxx-commits] [libcxx] [libc++][test] Fix construction and comparison for testing allocators (PR #212702)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 29 02:12:54 PDT 2026


================
@@ -195,8 +195,14 @@ class test_allocator {
       ++stats_->destroy_count;
     p->~T();
   }
-  TEST_CONSTEXPR friend bool operator==(const test_allocator& x, const test_allocator& y) { return x.data_ == y.data_; }
-  TEST_CONSTEXPR friend bool operator!=(const test_allocator& x, const test_allocator& y) { return !(x == y); }
+  template <class U>
+  TEST_CONSTEXPR friend bool operator==(const test_allocator& x, const test_allocator<U>& y) {
+    return x.data_ == static_cast<const test_allocator&>(y).data_;
----------------
frederick-vs-ja wrote:

The `static_cast` works around https://gcc.gnu.org/PR120684 which is fixed in GCC 15.2 and 16.

https://github.com/llvm/llvm-project/pull/212702


More information about the libcxx-commits mailing list