Skip to content

Commit 0c70565

Browse files
[libc++] Remove potential 0-sized array in __compressed_pair_padding
1 parent fc06c00 commit 0c70565

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

libcxx/include/__memory/compressed_pair.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
5252

5353
#ifndef _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
5454

55-
template <class _ToPad>
55+
template <class _ToPad,
56+
bool _Empty = ((is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) ||
57+
is_reference<_ToPad>::value || sizeof(_ToPad) - __datasizeof_v<_ToPad> == 0)>
5658
class __compressed_pair_padding {
57-
char __padding_[((is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) || is_reference<_ToPad>::value)
58-
? 0
59-
: sizeof(_ToPad) - __datasizeof_v<_ToPad>];
59+
char __padding_[sizeof(_ToPad) - __datasizeof_v<_ToPad>];
6060
};
6161

62+
template <class _ToPad>
63+
class __compressed_pair_padding<_ToPad, true> {};
64+
6265
# define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \
6366
_LIBCPP_NO_UNIQUE_ADDRESS __attribute__((__aligned__(_LIBCPP_ALIGNOF(T2)))) T1 Initializer1; \
6467
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \

0 commit comments

Comments
 (0)