This is what I got when I tried clang++ -cc1 -ast-dump
on your code
class B : virtual public A {
class B;
public:
B() : A() (CompoundStmt 0xb85950 <a.cpp:9:5, line:11:5>)
B(A const &a) : A() (CompoundStmt 0xb859c0 <a.cpp:13:5, line:15:5>)
inline B &operator=(B const &) throw();
inline void ~B() throw();
inline B(B const &) throw() : A((ImplicitCastExpr 0xb86a10 <a.cpp:5:7> 'clas
s A const' <UncheckedDerivedToBase (virtual A)> lvalue
(DeclRefExpr 0xb869ec <col:7> 'class B const' ParmVar='' 0xb86170))
) (CompoundStmt 0xb86ab0 <a.cpp:5:7>)
As you can see your class B
has an implicitly declared(compiler synthesized) copy ctor.
inline B(B const &) throw():
which is a better match for type C
argument as James McNellis said in his answer. That's why you do not see a call to B(const A& a)
because it never gets called actually.