[libc++] Remove potential 0-sized array in __compressed_pair_padding#109028
[libc++] Remove potential 0-sized array in __compressed_pair_padding#109028
Conversation
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-libcxx Author: None (serge-sans-paille) ChangesFull diff: https://github.com/llvm/llvm-project/pull/109028.diff 1 Files Affected:
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__, _); \
|
|
In the spirit of #105865 - I don't think we can use a similar implementation as what we did there, but that's the same idea / motivation |
a64e67a to
0c70565
Compare
0c70565 to
dae40cd
Compare
| 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>]; |
There was a problem hiding this comment.
Can't we reuse the same __padding struct we now have in <string>?
|
It's not clear to me if the issue here come from the CI system or from my patch :-/ |
shafik
left a comment
There was a problem hiding this comment.
This needs a more detailed summary, e.g. what is the motivation for this change?
|
Please rebase onto main to re-trigger CI. The CI instability should be resolved now. |
3d28f77 to
1112cfd
Compare
ba11fce to
cb61492
Compare
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
87b87bd to
4ddd5a7
Compare
4ddd5a7 to
0ab7824
Compare
|
@shafik : I'm trying to have libcxx compile with @ldionne : I undid the reuse of |
…m#142516) This PR mirrors changes of `__compressed_pair_padding` in libc++ into lldb test suite. Related PR for libc++: - llvm#108956 - llvm#109028 - llvm#142125 (cherry picked from commit 119705e)
…m#142516) This PR mirrors changes of `__compressed_pair_padding` in libc++ into lldb test suite. Related PR for libc++: - llvm#108956 - llvm#109028 - llvm#142125 (cherry picked from commit 119705e) (cherry picked from commit 205591b)
…m#142516) This PR mirrors changes of `__compressed_pair_padding` in libc++ into lldb test suite. Related PR for libc++: - llvm#108956 - llvm#109028 - llvm#142125 (cherry picked from commit 119705e) (cherry picked from commit 205591b)
No description provided.