Subject: Re: [std-proposals] Idea: extend forward declarations to include base class(s)
From: John Yates (john_at_[hidden])
Date: 2020-02-22 14:49:36
On Sat, Feb 22, 2020 at 2:22 PM Thiago Macieira via Std-Proposals <
> On Friday, 21 February 2020 09:53:34 PST John Yates via Std-Proposals
> > 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
> definition is usually needed to determine what adjustment is needed to
> 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
and thier inheritance relationships without providing any more information.
On most ABIs, the first non-virtual base ("primary" base) shares the same
> 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;
> struct D : virtual B;
To me a forward declaration of either of those structs as simply struct D:
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
STD-PROPOSALS list run by herb.sutter at gmail.com
Standard Proposals Archives on Google Groups