From bd910ae6999437ab1c89923640ad374c3252c90b Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Thu, 29 Aug 2024 10:30:34 +0200 Subject: [PATCH] fixup! [libc++][string] Remove potential non-trailing 0-length array --- libcxx/include/string | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libcxx/include/string b/libcxx/include/string index 8cbda52fa4ebbf..805831a16720b1 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -750,7 +750,7 @@ struct __init_with_sentinel_tag {}; #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT template -struct __short_impl { +struct __short_layout_alternate { _CharT __data_[__min_cap]; unsigned char __padding_[_Padding]; unsigned char __size_ : 7; @@ -758,14 +758,14 @@ struct __short_impl { }; template -struct __short_impl<_CharT, __min_cap, 0> { +struct __short_layout_alternate<_CharT, __min_cap, 0> { _CharT __data_[__min_cap]; unsigned char __size_ : 7; unsigned char __is_long_ : 1; }; #else template -struct __short_impl { +struct __short_layout_classic { struct _LIBCPP_PACKED { unsigned char __is_long_ : 1; unsigned char __size_ : 7; @@ -774,7 +774,7 @@ struct __short_impl { _CharT __data_[__min_cap]; }; template -struct __short_impl<_CharT, __min_cap, 0> { +struct __short_layout_classic<_CharT, __min_cap, 0> { struct _LIBCPP_PACKED { unsigned char __is_long_ : 1; unsigned char __size_ : 7; @@ -929,7 +929,11 @@ private: #endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT - using __short = __short_impl; +#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT + using __short = __short_layout_alternate ; +#else + using __short = __short_layout_classic ; +#endif static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size."); union __rep {