Here is a testcase that fails in 4.0 CVS, but works in 3.4. -------------------- extern "C" void printf (const char*, ...); struct Model { bool full_tree; // if you remove this, the error goes away virtual Model* clone() const =0; virtual char *name() const =0; virtual ~Model() {} // if you remove this, the error goes away }; struct R: virtual public Model { virtual R* clone() const =0; }; struct A: virtual public Model { virtual A* clone() const=0; }; struct RA: public R, public A { virtual RA* clone() const=0; }; //--------------------- EQU Model ------------------------// struct EQU: public RA { virtual EQU* clone() const {return new EQU(*this);} char *name() const {return "EQU";} }; int main() { Model* M1 = new EQU(); Model* M2 = M1->clone(); Model* M3 = M2->clone(); printf("subst model = %s \n", M1->name() ); printf("subst model = %s \n", M2->name() ); printf("subst model = %s \n", M3->name() );
return 0; } -- Summary: Covariant returns broke Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bredelin at ucla dot edu CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19891