-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[libc++] Remove potential 0-sized array in __compressed_pair_padding #109028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we reuse the same __padding
struct we now have in <string>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed
It's not clear to me if the issue here come from the CI system or from my patch :-/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
No description provided.