[libcxx-commits] [libcxx] [libc++] Fix bug in **tests** for std::atomic_ref<T*> increment and decrement operators (PR #122271)

Damien L-G via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jan 9 07:24:17 PST 2025


================
@@ -42,43 +42,79 @@ constexpr bool does_not_have_increment_nor_decrement_operators() {
 
 template <typename T>
 struct TestDoesNotHaveIncrementDecrement {
-  void operator()() const { static_assert(does_not_have_increment_nor_decrement_operators<T>()); }
+  void operator()() const { static_assert(does_not_have_increment_nor_decrement_operators<std::atomic_ref<T>>()); }
 };
 
 template <typename T>
 struct TestIncrementDecrement {
   void operator()() const {
-    static_assert(std::is_integral_v<T>);
-
-    T x(T(1));
-    std::atomic_ref<T> const a(x);
-
-    {
-      std::same_as<T> decltype(auto) y = ++a;
-      assert(y == T(2));
-      assert(x == T(2));
-      ASSERT_NOEXCEPT(++a);
-    }
-
-    {
-      std::same_as<T> decltype(auto) y = --a;
-      assert(y == T(1));
-      assert(x == T(1));
-      ASSERT_NOEXCEPT(--a);
-    }
-
-    {
-      std::same_as<T> decltype(auto) y = a++;
-      assert(y == T(1));
-      assert(x == T(2));
-      ASSERT_NOEXCEPT(a++);
-    }
-
-    {
-      std::same_as<T> decltype(auto) y = a--;
-      assert(y == T(2));
-      assert(x == T(1));
-      ASSERT_NOEXCEPT(a--);
+    static_assert(std::is_integral_v<T> || std::is_pointer_v<T>);
----------------
dalg24 wrote:

Didn't mean to keep that static assert but not sure it is worth retriggering the CI

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


More information about the libcxx-commits mailing list