extern(C++) multiple inheritence

Manu via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 25 21:02:02 PST 2016


On 24 January 2016 at 20:40, Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On 1/22/2016 5:46 PM, Manu via Digitalmars-d wrote:
>>
>> I brought a work laptop home this weekend in anticipation ;)
>
>
> Here ya go:
>
>   https://github.com/D-Programming-Language/dmd/pull/5364
>
> Be wary of:
>
>   https://issues.dlang.org/show_bug.cgi?id=15589
>
> and use the workaround as necessary. This is lower priority, so I won't be
> dealing with it for a bit.

Next blocker: https://issues.dlang.org/show_bug.cgi?id=15610

C++ methods with multiple-inheritence expect that 'this' is a pointer
to the base class that introduced the function.
When using C++ 'interface's, which C++ just treats like normal
multiple-inheritence, C++ expects that the 'this' pointer is adjusted
to the offset of the interface's vtable.

If I have:
extern(C++) interface Interface { voif f(); }
extern(C++) class C : Base, Interface
{
  void f();
}

Calling c.f(), D is passing 'this' unaltered, but C++ expects 'this'
is a pointer to 'Interface', and then it crashes accessing members at
incorrect offsets.


More information about the Digitalmars-d mailing list