Date: Thu, 18 Jul 2024 14:36:49 -0400
On Thu, Jul 18, 2024 at 2:05 PM Thiago Macieira via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> On Thursday 18 July 2024 09:09:59 GMT-7 Sebastian Wittmeier via
> Std-Proposals
> wrote:
> > Trivial lists
> >
> > pair, span, string_view
>
> Given that std::pair must have a member called "first" and one called
> "second"
> and their initialisation order is defined, they are effectively
> data-layout-
> compatible. Whether they are fully compatible will depend on whether the
> types
> are "trivial for the purposes of function calling" - that is, will they be
> passed in registers or not? I don't know if the Standard allows std::pair
> to
> be trivial if the template parameter types are themselves trivial. Even
> then,
> a compiler could force the function-passing ABI to trivial in that case.
>
The Standard allows triviality, yes. But for historical (ABI!) reasons some
libraries don't make `pair` fully as trivial as possible.
libc++ is actually in the process of making their `std::pair` "more
trivial" right now as we speak:
https://github.com/llvm/llvm-project/pull/95444
https://github.com/llvm/llvm-project/pull/89652
It might be instructive to read the discussion threads on those PRs.
I think `pair` and `string` are the most potentially informative examples
to look at here. They clearly do have "ABI issues" in the real world — but
they have those issues precisely because they're active research areas. So
they are simultaneously important candidates to "make stable"; but that's
because they are fundamentally unstable; and *that* is because it's not
clear how to make them stable.
So, actually trying to "make a stable std::pair" yourself [i.e., Hansself]
(as a third-party library) would be a great exercise, because it would
replicate in miniature all the issues that STL vendors already have to deal
with — it would show why "ABI" is not a simple problem with a simple
solution.
–Arthur
std-proposals_at_[hidden]> wrote:
> On Thursday 18 July 2024 09:09:59 GMT-7 Sebastian Wittmeier via
> Std-Proposals
> wrote:
> > Trivial lists
> >
> > pair, span, string_view
>
> Given that std::pair must have a member called "first" and one called
> "second"
> and their initialisation order is defined, they are effectively
> data-layout-
> compatible. Whether they are fully compatible will depend on whether the
> types
> are "trivial for the purposes of function calling" - that is, will they be
> passed in registers or not? I don't know if the Standard allows std::pair
> to
> be trivial if the template parameter types are themselves trivial. Even
> then,
> a compiler could force the function-passing ABI to trivial in that case.
>
The Standard allows triviality, yes. But for historical (ABI!) reasons some
libraries don't make `pair` fully as trivial as possible.
libc++ is actually in the process of making their `std::pair` "more
trivial" right now as we speak:
https://github.com/llvm/llvm-project/pull/95444
https://github.com/llvm/llvm-project/pull/89652
It might be instructive to read the discussion threads on those PRs.
I think `pair` and `string` are the most potentially informative examples
to look at here. They clearly do have "ABI issues" in the real world — but
they have those issues precisely because they're active research areas. So
they are simultaneously important candidates to "make stable"; but that's
because they are fundamentally unstable; and *that* is because it's not
clear how to make them stable.
So, actually trying to "make a stable std::pair" yourself [i.e., Hansself]
(as a third-party library) would be a great exercise, because it would
replicate in miniature all the issues that STL vendors already have to deal
with — it would show why "ABI" is not a simple problem with a simple
solution.
–Arthur
Received on 2024-07-18 18:37:05