[libcxx-commits] [libcxx] [libc++] Remove potential 0-sized array in __compressed_pair_padding (PR #109028)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Sep 17 11:43:08 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: None (serge-sans-paille)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/109028.diff
1 Files Affected:
- (modified) libcxx/include/__memory/compressed_pair.h (+6-4)
``````````diff
diff --git a/libcxx/include/__memory/compressed_pair.h b/libcxx/include/__memory/compressed_pair.h
index 629e3ad8848ffa..cc56912f5e34c5 100644
--- a/libcxx/include/__memory/compressed_pair.h
+++ b/libcxx/include/__memory/compressed_pair.h
@@ -52,13 +52,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
-template <class _ToPad>
+template <class _ToPad,
+ bool _Empty = ((is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) || is_reference<_ToPad>::value)>
class __compressed_pair_padding {
- char __padding_[((is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) || is_reference<_ToPad>::value)
- ? 0
- : sizeof(_ToPad) - __datasizeof_v<_ToPad>];
+ char __padding_[sizeof(_ToPad) - __datasizeof_v<_ToPad>];
};
+template <class _ToPad>
+class __compressed_pair_padding<_ToPad, true> {};
+
# define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \
_LIBCPP_NO_UNIQUE_ADDRESS __attribute__((__aligned__(_LIBCPP_ALIGNOF(T2)))) T1 Initializer1; \
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \
``````````
</details>
https://github.com/llvm/llvm-project/pull/109028
More information about the libcxx-commits
mailing list