[libcxx-commits] [libcxx] Unconditionally lower std::string's alignment requirement from 16 to 8. (PR #68925)
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 23 13:21:44 PST 2024
mstorsjo wrote:
> @mstorsjo
>
> > I see an ABI break being mentioned in the commit message, as being noted and agreed to be acceptable. I'm interested to hear about all the aspects of ABI break that was considered and deemed acceptable.
>
> This changes the value returned by `std::basic_string::max_size()`, which could in theory be relied upon, but in practice no sane code would ever rely on that for anything serious. In fact, the output of that function was wrong for 10+ years and we changed it a couple of releases ago. IMO changing the value returned by this function is as much of an ABI break as changing the return value of any other function to e.g. fix a bug -- it's really not much of a break.
>
> > In particular, won't this also break the layout of user's data structures? If I have e.g. `struct { char c; std::string str; }`, this struct will now have a different layout after this change, effectively breaking the ABI of potentially any struct/class that embeds a string?
>
> No, this only affects the alignment of the data allocated by the string in long mode. This doesn't change the layout of the `std::string` object itself.
Oh, ok - thanks, that clears my concern! Yes this sounds perfectly safe to me then.
https://github.com/llvm/llvm-project/pull/68925
More information about the libcxx-commits
mailing list