Skip to content

Commit d5c8412

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

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

libcxx/include/string

+9-5
Original file line numberDiff line numberDiff line change
@@ -750,22 +750,22 @@ struct __init_with_sentinel_tag {};
750750

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

760760
template <class _CharT, size_t __min_cap>
761-
struct __short_impl<_CharT, __min_cap, 0> {
761+
struct __short_layout_alternate<_CharT, __min_cap, 0> {
762762
_CharT __data_[__min_cap];
763763
unsigned char __size_ : 7;
764764
unsigned char __is_long_ : 1;
765765
};
766766
#else
767767
template <class _CharT, size_t __min_cap, size_t _Padding = sizeof(_CharT) - 1>
768-
struct __short_impl {
768+
struct __short_layout_classic {
769769
struct _LIBCPP_PACKED {
770770
unsigned char __is_long_ : 1;
771771
unsigned char __size_ : 7;
@@ -774,7 +774,7 @@ struct __short_impl {
774774
_CharT __data_[__min_cap];
775775
};
776776
template <class _CharT, size_t __min_cap>
777-
struct __short_impl<_CharT, __min_cap, 0> {
777+
struct __short_layout_classic<_CharT, __min_cap, 0> {
778778
struct _LIBCPP_PACKED {
779779
unsigned char __is_long_ : 1;
780780
unsigned char __size_ : 7;
@@ -929,7 +929,11 @@ private:
929929

930930
#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
931931

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

935939
union __rep {

0 commit comments

Comments
 (0)