please see the following code
struct A { using type = int; };
struct B : private A {};
struct C : B { using base_type = A; };
All of gcc 6.1, clang 3.8, and msvc 2015 update 3 refuse to compile this, as A
is not an accessible name inside C
since A
is a private base of B
. It seems that gcc thinks A
in using base_type = A
refers to the default constructor of A
. msvc and clang seem not.
Perhaps the compilation error is due to the injection of names triggered by inheritances (because modifying using base_type = A
into using base_type = ::A
make all the compilers work fine), but I want to know if this weird error is what the standard says.
More concretely,
- As I understood, not like
A::type
,A
is just a class name (although gcc misinterprets it as a function name) which is introduced toC
not insideA
norB
. Why this name is considered private toB
? - Should this compilation error be considered a bug, or is an edge case of the specifications of the standard?
A
insideC
works. First it checks to find if anything is declared with a nameA
in the scope ofC
beforeusing
. Since it does not find one, it is checking it in the scope ofB
since it's the Base class. And in case it does not findA
inB
s scope, it will look out in theglobal namespace
. But somehow theprivate inheritance
ofA
byB
is getting stopped at the second lookup i.e inside the scope ofB
. Since it works usingfully qualified
name, that makes me think that the real issue must be on the same lines. – Roxanneroxburgh