[libcxx-commits] [libcxx] [libc++] Ensure that `std::expected` has no tail padding (PR #69673)
Jan Kokemüller via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Oct 27 09:50:57 PDT 2023
jiixyj wrote:
> One think I'm still unsure about is the layout of the union itself.
I have convinced myself that making the union members unconditionally `[[no_unique_address]]` is the way to go. Pessimizing `expected`'s data layout because of GCC's decision to prevent guaranteed copy elision into partially overlapping subobjects (for which there are good reasons!) is not worth it, I think. In `expected`'s case, we control all tail padding bytes, so guaranteed copy elision into the union members is perfectly safe. Making the layout depend on move constructor triviality seems also a bit brittle to me. I have asked at the GCC bug if there can be a way for a `[[no_unique_address]]` member to declare "yes, please allow guaranteed copy elision into me": <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98995#c13>
https://github.com/llvm/llvm-project/pull/69673
More information about the libcxx-commits
mailing list