This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++ does not resolve operator = correctly
- To: gcc-bugs at gcc dot gnu dot org
- Subject: g++ does not resolve operator = correctly
- From: Xavier Van Elsacker <xavier at CoWare dot com>
- Date: Mon, 03 Jul 2000 19:42:22 +0200
- Organization: CoWare
g++ 2.95.2 resolves the assignment in the following
piece of code to the pure virtual assign on the base
class, instead of making it a virtual call.
I compiled without any compilation flags, (g++ assign.cc),
on SUN and HP, also tried 2.81 with the same result.
#include <iostream.h>
class base {
public:
virtual const base &operator = (const base &) = 0;
};
class derived : public base {
public:
virtual const base &operator = (const base &rhs);
};
void func(derived *b, derived *c) {
*b = *c;
}
int main() {
derived a;
derived b;
func(&a, &b);
return 0;
}
const base &base::operator = (const base &rhs) {
cout << "base assign called" << endl;
return rhs;
}
const base &derived::operator = (const base &rhs) {
cout << "derived assign called" << endl;
return rhs;
}