Skip to content

Commit 0eb2602

Browse files
[libc++] Remove potential 0-sized array in __compressed_pair_padding (#109028)
1 parent 54a4965 commit 0eb2602

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

libcxx/include/__format/format_arg_store.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ struct __packed_format_arg_store {
234234
uint64_t __types_ = 0;
235235
};
236236

237+
template <class _Context>
238+
struct __packed_format_arg_store<_Context, 0> {
239+
uint64_t __types_ = 0;
240+
};
241+
237242
template <class _Context, size_t _Np>
238243
struct __unpacked_format_arg_store {
239244
basic_format_arg<_Context> __args_[_Np];

libcxx/include/__memory/compressed_pair.h

Lines changed: 7 additions & 4 deletions
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>)>
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)