This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Several levels of virtual inheritance: bug?



On Feb 10, 2005, at 6:46 PM, Benjamin Redelings I wrote:


Hello,

I have found (what seems to be) a bug in todays CVS version of g++ 4.0. The reduced testcase no logner calls the wrong virtual function, but it still crashes. Additionally it is all one file now.
I attatched a reduced test-case (test-smodel.C). Here is the output:

Yes please file a bug.


Also this looks like covariant returns has regressed from 3.4 which is bad as it
was a new feature for 3.4.


Note here is even further reduced testcase (without any dependancies on headers):

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;
}


-- Pinski



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]