From 72ff46de5c4376b23bdb2a4adc0f35a957667ea1 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Sun, 8 Sep 2024 09:31:49 +0200 Subject: [PATCH] fixup! fixup! [libc++][string] Remove potential non-trailing 0-length array --- libcxx/include/string | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/libcxx/include/string b/libcxx/include/string index 4a0aa0ce48e539..a4daaed748aa19 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -749,40 +749,31 @@ struct __can_be_converted_to_string_view struct __uninitialized_size_tag {}; struct __init_with_sentinel_tag {}; -#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT +template +struct __padding { + char __padding_[_PaddingSize]; +}; + +template <> +struct __padding<0> {}; + template struct __short_layout_alternate { _CharT __data_[__min_cap]; - unsigned char __padding_[_Padding]; + _LIBCPP_NO_UNIQUE_ADDRESS __padding<_Padding> __padding_; unsigned char __size_ : 7; unsigned char __is_long_ : 1; }; -template -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_layout_classic { struct _LIBCPP_PACKED { unsigned char __is_long_ : 1; unsigned char __size_ : 7; }; - char __padding_[_Padding]; - _CharT __data_[__min_cap]; -}; -template -struct __short_layout_classic<_CharT, __min_cap, 0> { - struct _LIBCPP_PACKED { - unsigned char __is_long_ : 1; - unsigned char __size_ : 7; - }; + _LIBCPP_NO_UNIQUE_ADDRESS __padding<_Padding> __padding_; _CharT __data_[__min_cap]; }; -#endif template class basic_string {