crystal clear()

Sean Kelly sean at invisibleduck.org
Sat Sep 18 07:03:37 PDT 2010


Andrei Alexandrescu Wrote:

> On 09/17/2010 05:30 PM, Sean Kelly wrote:
> > Steven Schveighoffer Wrote:
> >>
> >> But here is a legitimate question, how do we get the interfaces?  There's
> >> no indication in the ABI of where the interfaces are.  I know from logic
> >> that they must be before the data members.  But logic also says that
> >> interfaces defined by the derived types must appear after the data members
> >> of the base class.  This is indeed tricky.
> >
> > I'd guess that the interface vtbls are referenced from the class vtbl, so clearing the vptr should wipe everything.
> 
> Actually, casting to an interface adds a constant offset to the pointer 
> to the object without using the vptr at all. The shared referencing you 
> might be thinking about is the actual function addresses: portions of 
> the main vtable are identical with the interfaces vtables.

Oh right, altering the object's vtbl ptr would effectively cast it for all references to the object.  Ah well.  In that case, I'm not entirely sure how this works :-)  Would love an explanation.


More information about the Digitalmars-d mailing list