Date: Sat, 22 Feb 2020 15:49:36 -0500
On Sat, Feb 22, 2020 at 2:22 PM Thiago Macieira via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> On Friday, 21 February 2020 09:53:34 PST John Yates via Std-Proposals
> wrote:
> > struct D : B;
> >
> > I am not enough of a language lawyer to know why this would not work and
> > whether it might have problems in the presence of multiple base classes.
>
> That only works if B is not forward-declared and maybe not even then. The
> full
> definition is usually needed to determine what adjustment is needed to
> apply
> to the pointers in order to transform a D to a B.
>
Well that is a bummer. I really want to provide forward declarations of my
object
and thier inheritance relationships without providing any more information.
On most ABIs, the first non-virtual base ("primary" base) shares the same
> top
> address as the derived class, so you could convert a D to a B without
> adjustment, but not so in the case of:
>
> struct D : A, B;
> or
> struct D : virtual B;
>
To me a forward declaration of either of those structs as simply struct D:
B;
is clearly an error. When forward declaring base classes any failure to
match exactly the actual declaration (number, order, virtualness, etc.)
should at the very least be UB.
std-proposals_at_[hidden]> wrote:
> On Friday, 21 February 2020 09:53:34 PST John Yates via Std-Proposals
> wrote:
> > struct D : B;
> >
> > I am not enough of a language lawyer to know why this would not work and
> > whether it might have problems in the presence of multiple base classes.
>
> That only works if B is not forward-declared and maybe not even then. The
> full
> definition is usually needed to determine what adjustment is needed to
> apply
> to the pointers in order to transform a D to a B.
>
Well that is a bummer. I really want to provide forward declarations of my
object
and thier inheritance relationships without providing any more information.
On most ABIs, the first non-virtual base ("primary" base) shares the same
> top
> address as the derived class, so you could convert a D to a B without
> adjustment, but not so in the case of:
>
> struct D : A, B;
> or
> struct D : virtual B;
>
To me a forward declaration of either of those structs as simply struct D:
B;
is clearly an error. When forward declaring base classes any failure to
match exactly the actual declaration (number, order, virtualness, etc.)
should at the very least be UB.
-- John Yates 505 Tremont St, #803 Boston, MA 02116
Received on 2020-02-22 14:52:30