[libcxx-commits] [libcxx] Lower std::string's alignment requirement from 16 to 8. (PR #68749)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 10 16:50:46 PDT 2023


================
@@ -167,6 +167,11 @@
 // The implementation moved to the header, but we still export the symbols from
 // the dylib for backwards compatibility.
 #    define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
+// Same memory by providing the allocator more freedom to allocate the most
+// efficient size class by dropping the alignment requirements for std::string's
+// pointer from 16 to 8. This changes the output of std::string::max_size,
+// which makes it ABI breaking
----------------
ldionne wrote:

Ah, I just saw this is actually https://reviews.llvm.org/D155486 IIUC. This provides more background, I see now. Can we abandon that change to clear up our Phabricator queue, or is there stuff left in that patch that we still need to migrate over to Github (or drop).

Coming back to the change itself, FWIW I think I would be happy with going for the "ABI break". Yes this could technically result in ODR violations, but in practice I can hardly imagine someone depending on the exact value of `max_size()`, whose documentation is:

> Returns the maximum number of elements the string is able to hold due to system or library implementation limitations, i.e. `std::distance(begin(), end())` for the largest string.

https://github.com/llvm/llvm-project/pull/68749


More information about the libcxx-commits mailing list