[libcxx-commits] [libcxx] Fix bug in atomic_ref's calculation of lock_free-ness. (PR #93427)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jun 25 07:40:44 PDT 2024
================
@@ -42,6 +42,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
+// These types are required to make __atomic_is_always_lock_free work across GCC and Clang.
+// GCC won't allow the reinterpret_cast<_Tp*>(-required_alignment) trick initially used,
+// so we need to actually fake up an instance of a type with the correct alignment.
----------------
ldionne wrote:
```suggestion
// These types are required to make __atomic_is_always_lock_free work across GCC and Clang.
// The purpose of this trick is to make sure that we provide an object with the correct alignment
// __atomic_is_always_lock_free, since whether the object is lock free depends on whether it is
// correctly aligned.
```
I'm worried that this part in the original comment would not age very well / provide long term value beyond this review:
> GCC won't allow the reinterpret_cast<_Tp*>(-required_alignment) trick initially used
https://github.com/llvm/llvm-project/pull/93427
More information about the libcxx-commits
mailing list