Wrong virtual function call
Wrong virtual function call
- Subject: Wrong virtual function call
- From: David Catmull <email@hidden>
- Date: Wed, 24 Jan 2007 09:37:06 -0800
I have a situation where the wrong virtual function is getting
called. I have tried cleaning and rebuilding to no avail.
The code looks something like this:
class A
{
public:
virtual GraphicsImp GetGraphics() = 0;
virtual Range GetRange(const RangeSpecifier&) = 0;
};
class B : public A, public C, public D
{
public:
virtual GraphicsImp GetGraphics() {...}
virtual Range GetRange(const RangeSpecifier&) {...}
};
void F(A *p)
{
p->GetRange(someSpec);
}
void G()
{
B b;
F(&b);
}
When F is called from G, B::GetGraphics() gets called instead of
B::GetRange(), resulting in a bogus range. Neither function exists in
C or D. I tried reordering B's inheritance, but that didn't help either.
Other subclasses of A do not have this problem. In fact, they go
through a "non-virtual thunk" which B does not.
So is this some kind of compiler bug? What can I do to get around it?
--
David Catmull
email@hidden
http://www.uncommonplace.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden