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]

Is this a bug of gcc ?


Hello,

I cannot compile a code that seems correct to me. I have tried with gcc 3.3 and gcc 4.0.1 on MacOS X-ppc, and gcc 4.0.1 on Linux i686.

Here is the code, that uses pure virtual functions and simple inheritance.

//-------------------------------------
struct a
{
  virtual int foo() =0;
  virtual ~a(){}
};

struct b : public a
{
  virtual int foo(int a) =0;
  virtual ~b(){}
};

struct c : public b
{
int test()
{
return (foo() + // <--- the compiler claims here that it cannot find foo()
foo(2));
}
virtual ~c(){}
};


struct d : public c
{
  virtual int foo() {return 1;}
  virtual int foo(int a) {return a;}
  virtual ~d(){}
};

int main()
{
  d call;
  return call.test();
}
//-------------------------------------

The compiler claims that it cannot find foo. I have found two possible workarounds :
-repeat the "virtual int foo() =0;" prototype in the declaration of struct b
or
-change the foo(void) function into a bar(void) function.


I am under the impression that it is a bug of gcc. Should I fill a bug, or am I the one who is confused ?

Pierre Chatelier


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