C++ Logo

std-proposals

Advanced search

Re: [std-proposals] ABI

From: Hans <hguijtra_at_[hidden]>
Date: Fri, 12 Jul 2024 12:54:24 +0200
On 12/07/2024 12:35, Ville Voutilainen wrote:
> On Fri, 12 Jul 2024 at 13:27, Hans via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>> Perhaps it would be worth taking a look at the paper, which answers all
>> of these questions. It suggests, as an initial list,
>> std::stable::string, std::stable::string_view, std::stable::vector, and
>> std::stable::span. It would probably also be good to add stable classes
>> for error handling.
>
>> The paper proposes that stable classes must be standard layout types.
>
> A completely unnecessary restriction.

Adding a vtable adds quite a bit of complexity:

- Changing anything about the list of virtual functions (adding,
removing, swapping) would break stability.

- Different compilers would have to agree on exactly how the vptr and
vtable are laid out.

- The vptr/vtable layout would have to be formally documented on the
language level if you want interoperability with other languages.

I don't know how feasible the second point would be.

>> Standard layout types have no V-tables.
>
> Neither do the types you list above.

Those types are just examples. The rule, as currently proposed, is 'no
V-tables'.

Arguably standard layout is not an absolutely perfect match for
stability, but it comes close, and I didn't want to come up with a
completely new definition before knowing if the proposal gets any interest.


Hans Guijt

Received on 2024-07-12 10:54:26