C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Extensible vtables -- Ensuring ABI isn't broken

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sun, 18 Feb 2024 14:48:12 -0500
On Sun, Feb 18, 2024 at 1:18 PM Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> On Saturday, 17 February 2024 13:37:59 PST Tiago Freire via Std-Proposals
> wrote:
> > What you are trying to do works for reasons that got nothing to do with C++,
> > it’s all UB that just happens to work in practice. C++ won’t be able to
> > help you because it is technically an ODR violation.
>
> Strictly speaking, it's IFNDR, not UB, but that's arguing semantics over what
> may work in practice and how silently breakage can happen if you make
> mistakes.
>
> You're also right that the C++ standard can't touch this right now because it
> doesn't know what a library is, much less a dynamically-linked one. But in my
> opinion that's an excuse for not solving the problem: libraries and dynamic
> linking have existed in mainstream for at least 30 years. The problems that
> need solving are real. Solving them in C++ will not be a single massive update
> to the standard and I actually doubt it will ever be contained completely
> inside the standard, but it should start somewhere. And that implies the
> standard should know about dynamic linking.

I would argue that the standard understands just fine what a library
is. To the standard, a library is just a bunch of translation units,
and that effectively models the behavior of static linking.

The problem is dynamic libraries. A dynamic library acts like a bunch
of TUs... except for when it doesn't. A dynamic library acts like a
separate program... except for when it doesn't. And then there's the
loading and unloading part, where a thing may or may not exist based
on runtime behavior. There isn't anything in the standard that comes
close to modelling the behavior of dynamic linking.

Of course, there's also the fact that the two major implementations of
dynamic linking don't exactly agree on all of the details.

Received on 2024-02-18 19:48:25