This is the mail archive of the gcc-bugs@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]

Re: Bug in handling virtual functions in egcs 1.0.3 and GCC 2.8.1


>>>>> Jonathan Mohr <mohrj@Berio.Augustana.AB.CA> writes:

> Under GCC 2.7.2.3, this works as expected.  Under GCC 2.8.1 and egcs
> 1.0.3, it invokes operator= in the Vector class (the base class) instead,
> even though it has been declared virtual.

> Is this a bug, or has the definition of standard C++ be revised to
> disallow virtually overloading operators?

I'm guessing you have code like

struct Base {
  ...
  virtual Base& operator=(const Base&);
};

struct Derived : public Base {
  ...
  virtual Derived& operator=(const Derived&);
};

and you expect the derived op= to override the base.  This was a
non-standard cfrontism that g++ supported for a while but has since been
disabled; it's never been part of standard C++.

If you want to override the Base op=, you need to define an op= taking a
const Base&.

Jason


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