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; }
Confirmed. Note covariant returns were not implemented for 3.3.3 so we just gave an error.
Subject: Bug 19891 CVSROOT: /cvs/gcc Module name: gcc Changes by: nathan@gcc.gnu.org 2005-02-14 09:36:35 Modified files: gcc/cp : ChangeLog class.c search.c typeck.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/abi: covariant4.C Log message: cp: PR c++/19891 * class.c (build_simple_base_path): Build the component_ref directly. (update_vtable_entry_for_fn): Walk the covariant's binfo chain rather than using lookup_base. * search.c (dfs_walk_once): Add non-recursive assert check. * typeck.c (build_class_member_access_expr): It is possible for the member type to be both const and volatile. testsuite: PR c++/19891 * g++.dg/abi/covariant4.C: New. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4625&r2=1.4626 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.703&r2=1.704 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/search.c.diff?cvsroot=gcc&r1=1.344&r2=1.345 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.613&r2=1.614 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5028&r2=1.5029 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/abi/covariant4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
2005-02-11 Nathan Sidwell <nathan@codesourcery.com> PR c++/19891 * class.c (build_simple_base_path): Build the component_ref directly. (update_vtable_entry_for_fn): Walk the covariant's binfo chain rather than using lookup_base. * search.c (dfs_walk_once): Add non-recursive assert check. * typeck.c (build_class_member_access_expr): It is possible for the member type to be both const and volatile.