[libcxx-commits] [libcxx] [libc++] make std::atomic works with types with paddings (PR #76180)
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 22 11:25:56 PST 2023
================
@@ -26,6 +27,32 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR void __clear_padding_if_needed(_Tp* __ptr) noexcept {
+#if _LIBCPP_STD_VER >= 20
+ constexpr bool __needs_clear_padding =
+ !__has_unique_object_representations(_Tp) && !is_same<_Tp, float>::value && !is_same<_Tp, double>::value;
----------------
mordante wrote:
Is it guaranteed `float` and `double` never have padding. Wouldn't it be better to have a builtin that tells whether padding should be removed? Or even make the builtin a no-op when it's not needed for the type.
https://github.com/llvm/llvm-project/pull/76180
More information about the libcxx-commits
mailing list