Skip to content

Commit f17a954

Browse files
fixup! [libc++][string] Remove potential non-trailing 0-length array
1 parent 960e989 commit f17a954

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

libcxx/include/string

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -751,22 +751,22 @@ struct __init_with_sentinel_tag {};
751751

752752
#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
753753
template <class _CharT, size_t __min_cap, size_t _Padding = sizeof(_CharT) - 1>
754-
struct __short_impl {
754+
struct __short_layout_alternate {
755755
_CharT __data_[__min_cap];
756756
unsigned char __padding_[_Padding];
757757
unsigned char __size_ : 7;
758758
unsigned char __is_long_ : 1;
759759
};
760760

761761
template <class _CharT, size_t __min_cap>
762-
struct __short_impl<_CharT, __min_cap, 0> {
762+
struct __short_layout_alternate<_CharT, __min_cap, 0> {
763763
_CharT __data_[__min_cap];
764764
unsigned char __size_ : 7;
765765
unsigned char __is_long_ : 1;
766766
};
767767
#else
768768
template <class _CharT, size_t __min_cap, size_t _Padding = sizeof(_CharT) - 1>
769-
struct __short_impl {
769+
struct __short_layout_classic {
770770
struct _LIBCPP_PACKED {
771771
unsigned char __is_long_ : 1;
772772
unsigned char __size_ : 7;
@@ -775,7 +775,7 @@ struct __short_impl {
775775
_CharT __data_[__min_cap];
776776
};
777777
template <class _CharT, size_t __min_cap>
778-
struct __short_impl<_CharT, __min_cap, 0> {
778+
struct __short_layout_classic<_CharT, __min_cap, 0> {
779779
struct _LIBCPP_PACKED {
780780
unsigned char __is_long_ : 1;
781781
unsigned char __size_ : 7;
@@ -930,7 +930,11 @@ private:
930930

931931
#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
932932

933-
using __short = __short_impl<value_type, __min_cap>;
933+
#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
934+
using __short = __short_layout_alternate<value_type, __min_cap>;
935+
#else
936+
using __short = __short_layout_classic<value_type, __min_cap>;
937+
#endif
934938
static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size.");
935939

936940
union __rep {

0 commit comments

Comments
 (0)