[libcxx-commits] [PATCH] D127672: [libc++] Test the size of basic_string
Hubert Tong via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 16 16:38:35 PDT 2022
hubert.reinterpretcast added inline comments.
================
Comment at: libcxx/test/libcxx/strings/basic.string/alignof.compile.pass.cpp:99
+static_assert(alignof(test_string<char>) == 4, "");
+static_assert(alignof(small_string<char>) == 2, "");
+
----------------
hubert.reinterpretcast wrote:
> hubert.reinterpretcast wrote:
> > hubert.reinterpretcast wrote:
> > > This used to pass on AIX, but changes to use bitfields (without applying `_LIBCPP_PACKED_BYTE_FOR_AIX`) has broken this.
> > However, using the above also causes other members to be less aligned if padding is not explicitly added.
> Or rather it causes the string type to be less aligned.
```
--- string_20220520 2022-05-20 11:48:54.326820970 -0400
+++ string 2022-06-16 19:30:22.238194020 -0400
@@ -724,3 +724,4 @@
- struct __long
+_LIBCPP_PACKED_BYTE_FOR_AIX
+ struct __long_impl
{
@@ -729,2 +730,6 @@
size_type __size_;
+ char
+ __padding_[sizeof(pointer) *
+ ((2 * sizeof(size_type) - 1) / sizeof(pointer) + 1) -
+ 2 * sizeof(size_type)];
pointer __data_;
@@ -731,2 +736,4 @@
};
+_LIBCPP_PACKED_BYTE_FOR_AIX_END
+ struct alignas(size_type) alignas(pointer) __long : __long_impl {};
@@ -735,3 +742,4 @@
- struct __short
+_LIBCPP_PACKED_BYTE_FOR_AIX
+ struct __short_impl
{
@@ -742,2 +750,4 @@
};
+_LIBCPP_PACKED_BYTE_FOR_AIX_END
+ struct alignas(value_type) __short : __short_impl {};
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127672/new/
https://reviews.llvm.org/D127672
More information about the libcxx-commits
mailing list