[libcxx-commits] [libcxx] [libc++] Annotate the data member of variant with no_unique_address (PR #137783)

via libcxx-commits libcxx-commits at lists.llvm.org
Sat May 3 08:14:01 PDT 2025


huixie90 wrote:

> > I am not sure if you are aware of the bug that we had in std::expected, where we applied no_unique_address to the union.
> 
> Yeah I was aware of this issue. The current version of the PR is safe because the variant at the moment does not try to put the index in the tail padding of the user types. So what you're saying is that it _should_, and this ought to be implemented together with (conditionally) allowing users to reuse tail padding? The idea behind bundling it together is to not expand the zoo of potential variant layouts in the future, right?

Exactly. If this PR does not do that, I think we should, as we are creating a new ABI mode anyway 

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


More information about the libcxx-commits mailing list