[libcxx-commits] [PATCH] D128285: [libc++][AIX] Make basic_string layout compatible with earlier version

Hubert Tong via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jun 24 12:13:38 PDT 2022


hubert.reinterpretcast added inline comments.


================
Comment at: libcxx/include/string:758
 #endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
-
+    static_assert(sizeof(__long) == (sizeof(pointer) + 2 * sizeof(size_type) +
+                                     (sizeof(pointer) * ((2 * sizeof(size_type) - 1) / sizeof(pointer) + 1)) -
----------------
This reduces to:
```
((2 * sizeof(size_type) - 1) / sizeof(pointer) + 2) * sizeof(pointer)
```
but I think now that there are many other ways for this to go wrong (pointer requires less alignment than its size, alignment of size_type causes trailing padding, etc.).

Maybe:
```
struct __long_size_ref {
  size_type __x, __y;
  pointer __z;
};
static_assert(sizeof(__long) == sizeof(__long_size_ref));
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128285/new/

https://reviews.llvm.org/D128285



More information about the libcxx-commits mailing list