[llvm] [libc++] Ensure that `std::expected` has no tail padding (PR #69673)
Jan Kokemüller via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 20 13:20:55 PDT 2023
jiixyj wrote:
> @zygoloid s `repr_type` looks really promising. That should allow us to have a nice ABI and fix the bugs we currently have. @jiixyj could you try that version and check whether it actually fixes everything and gives us the nice ABI? (Note that you have to name the union to apply `[[no_unique_address]]`)
I had a shot at the `repr`/`compact_pair` approach and at looks good! The changes compared to <https://github.com/llvm/llvm-project/pull/68733> are in commit <https://github.com/llvm/llvm-project/pull/69673/commits/7f3144c38f17edf0be20789e69ee00e277110ec0> and overall pretty mechanical.
The only downside I see is that `expected`'s padding can never be used by another object. In other words, `sizeof(expected) == datasizeof(expected)` is always true.
> ... then apply `std::construct_at` to the `repr` member from `emplace`.
Wouldn't `std::construct_at` still be invalid, technically, when called on `__repr_.__union_.__val_`? Isn't that still a partially overlapping subobject?
https://github.com/llvm/llvm-project/pull/69673
More information about the llvm-commits
mailing list