In a "dreaded" diamon hierarchy
A0
|
A
/ \
B C
\ /
D
I get a request for a default constructor for A0 from the compiler
(gcc 3.4.4 )
If I drop A0, the error desappear.
testtemplate2.cpp: In constructor `B<TYPE>::B(int) [with TYPE = int]':
testtemplate2.cpp:57: instantiated from `D<TYPE>::D(int) [with TYPE =
int]'<int>::A0() �
testtemplate2.cpp:64: instantiated from here<int>::A0(const A0<int>&)
testtemplate2.cpp:37: erreur: pas de fonction concordante pour l'appel � �
A0<int>::A0() �
testtemplate2.cpp:15: note: candidats sont: A0<int>::A0(const A0<int>&)
testtemplate2.cpp:18: note: A0<TYPE>::A0(TYPE) [with TYPE = int]
testtemplate2.cpp: In constructor `C<TYPE>::C(int) [with TYPE = int]':
testtemplate2.cpp:57: instantiated from `D<TYPE>::D(int) [with TYPE = int]'
testtemplate2.cpp:64: instantiated from here
testtemplate2.cpp:47: erreur: pas de fonction concordante pour l'appel � �
A0<int>::A0() �
testtemplate2.cpp:15: note: candidats sont: A0<int>::A0(const A0<int>&)
testtemplate2.cpp:18: note: A0<TYPE>::A0(TYPE) [with TYPE = int]
template<class TYPE>
class A0
{ protected:
const int n;
public:
A0(TYPE a ) : n(a) { ;}
~A0() { ;}
virtual void foo() =0;
};
template<class TYPE>
class A : public virtual A0<TYPE>
{
public:
A(TYPE a ) : A0<TYPE>(a) { ;}
~A() { ;}
virtual void foo() =0;
};
template<class TYPE>
class B : public virtual A<TYPE>
{
public:
B(int b= 0) : A<TYPE>(b)
{ ;}
~B() { ;}
virtual void foo() =0;
};
template<class TYPE>
class C : public virtual A<TYPE>
{
public:
C(int c= 0) : A<TYPE>(c)
{ ;}
~C() { ;}
virtual void foo() =0;
};
template<class TYPE>
class D : public virtual B<TYPE>, public virtual C<TYPE>
{
public:
D(int d= 0) : A0<TYPE>(d), A<TYPE>(d), B<TYPE>(d), C<TYPE>(d)
{ ;}
~D() { ;}
virtual void foo() { ;}
};
int main(int argc, char *argv[])
{
D<int> d(4);
}
--
Summary: null constructor not needed in multiple inheritance
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Serge dot Iovleff at univ-lille1 dot fr
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20207