[libcxx-commits] [libcxx] [libcxx] makes `expected` trivially assignable when both members are … (PR #74768)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 16 14:16:36 PST 2024
philnik777 wrote:
> > @cjdb It would be great to land this before the release branch to get the ABI breaks into a single release.
>
> I actually considered the ABI aspect of this before, and I concluded that this wasn't ABI breaking since only trivial constructibility is taken into account for being trivial-for-the-purpose-of-ABI. From the [Itanium C++ ABI](https://itanium-cxx-abi.github.io/cxx-abi/abi.html#definitions):
>
> > _non-trivial for the purposes of calls_
> > A type is considered non-trivial for the purposes of calls if:
> >
> > * it has a non-trivial copy constructor, move constructor, or destructor, or
> > * all of its copy and move constructors are deleted.
> >
> > This definition, as applied to class types, is intended to be the complement of the definition in [class.temporary]p3 of types for which an extra temporary is allowed when passing or returning a type. A type which is trivial for the purposes of the ABI will be passed and returned according to the rules of the base C ABI, e.g. in registers; often this has the effect of performing a trivial copy of the type.
>
> Am I wrong? If this is an ABI break, we have to consider it way more carefully than I thought and TBH I think the LWG issue will probably come back as NAD.
It doesn't necessarily break calls, but it breaks the ABI in the sense that the layout of other types can change if the result of `is_trivially_copyable` and friends changes. Consider something like a `SmallVector` that only stores a few object in-place if the objects are trivially copyable to avoid branching when moving the `SmallVector`. While I don't think that's super likely to break anybody, it would be nice to avoid potentially breaking people multiple times.
https://github.com/llvm/llvm-project/pull/74768
More information about the libcxx-commits
mailing list