Date: Fri, 29 Sep 2023 07:47:58 -0700
On Friday, 29 September 2023 06:36:11 PDT Arthur O'Dwyer via Std-Proposals
wrote:
> One high-level concern which I *think* is moot but it would be nice to say
> so explicitly: Conversion from D* to B* requires dereferencing B* when D is
> a virtual base of B. Is that a "when and only when"? Or are there any
> other situations where that conversion might require dereferencing B*, that
> we should be thinking about?
> - Things that can require inspecting a vtable include dynamic_cast, typeid,
> and accesses through `int D::*` pointers-to-data-member that happen to
> point into a virtual base.
Pretty sure those require dereferencing already, whether the pointers in
question contain virtual bases or are virtual bases. Do note that "require
dereferencing" may not actually imply such in code generation, but does in the
Standard. For example:
ptr->f();
Does a dereference, even if f() is not a virtual member function. In fact, I
think the standard counts it as a dereference even if f() is a static member,
just because you wrote ->.
> - Things that do pointer conversions include static_pointer_cast,
> dynamic_pointer_cast, etc.
dynamic_pointer_cast, by its very name, is like those above: it already
dereferences on its own.
But static_pointer_cast should be documented to either not need it or to do
the necessary locking, both of which are what this trait is for.
wrote:
> One high-level concern which I *think* is moot but it would be nice to say
> so explicitly: Conversion from D* to B* requires dereferencing B* when D is
> a virtual base of B. Is that a "when and only when"? Or are there any
> other situations where that conversion might require dereferencing B*, that
> we should be thinking about?
> - Things that can require inspecting a vtable include dynamic_cast, typeid,
> and accesses through `int D::*` pointers-to-data-member that happen to
> point into a virtual base.
Pretty sure those require dereferencing already, whether the pointers in
question contain virtual bases or are virtual bases. Do note that "require
dereferencing" may not actually imply such in code generation, but does in the
Standard. For example:
ptr->f();
Does a dereference, even if f() is not a virtual member function. In fact, I
think the standard counts it as a dereference even if f() is a static member,
just because you wrote ->.
> - Things that do pointer conversions include static_pointer_cast,
> dynamic_pointer_cast, etc.
dynamic_pointer_cast, by its very name, is like those above: it already
dereferences on its own.
But static_pointer_cast should be documented to either not need it or to do
the necessary locking, both of which are what this trait is for.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel DCAI Cloud Engineering
Received on 2023-09-29 14:48:00