This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Bug in handling virtual functions in egcs 1.0.3 and GCC 2.8.1
- To: mohrj at Berio dot Augustana dot AB dot CA (Jonathan Mohr), egcs-bugs at cygnus dot com
- Subject: Re: Bug in handling virtual functions in egcs 1.0.3 and GCC 2.8.1
- From: Jason Merrill <jason at cygnus dot com>
- Date: 30 Jul 1998 17:13:04 -0700
- References: <Pine.LNX.3.96.980730142606.20938A-100000.cygnus.egcs.bugs@Berio.Augustana.AB.CA>
>>>>> 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