From [class.access]/7 we have the following sentence:
Similarly, the use of
A::B
as a base-specifier is well-formed becauseD
is derived fromA
, so checking of base-specifiers must be deferred until the entire base-specifier-list has been seen.
class A {
protected:
struct B { };
};
struct D: A::B, A { };
See live example with clang. As a matter of fact, clang also complains about this snippet, where no deferment is necessary.
class A {
protected:
struct B { };
};
struct D: A, A::B { };
Why does this code not compile?
PS: gcc and VS21013 don't compile the codes either.