• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Wrong virtual function call
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Wrong virtual function call [SOLVED]
      • From: David Catmull <email@hidden>
  • Prev by Date: Debugging .service
  • Next by Date: Re: Is there a 1GB memory ceiling for vm_allocate?
  • Previous by thread: Debugging .service
  • Next by thread: Re: Wrong virtual function call [SOLVED]
  • Index(es):
    • Date
    • Thread