extern(C++) classes; dtor must go in vtable
Manu
turkeyman at gmail.com
Mon May 21 22:34:25 UTC 2018
On 21 May 2018 at 15:03, Jonathan M Davis via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On Monday, May 21, 2018 14:33:44 Manu via Digitalmars-d wrote:
>> extern(C++) classes.
>>
>> Currently, we don't add destructors to the vtable... we suggest that
>> users need to create some dummy virtual functions to fill those vtable
>> slots so that the vtable layout otherwise matches the C++ class.
>>
>> This leaves us in a position where destruction doesn't work for
>> polymorphic types.
>
> How are you destroying any C++ types from D at all?
Awkwardly... and that's the whole point here ;)
That's what I intend to fix!
DMD will need to learn to call the first vtable slot for extern(C++)
destruction.
> extern(C++) classes get constructed and destroyed/deleted in C++ code.
For now...
It is a terrible inconvenience!
> I certainly have no problem with attempts to improve our integration with
> C++, but it sounds to me like you're talking like you're currently calling
> C++ destructors from D,
Correct. But it's all bullshit, and needs to die with fire. (or, die
with a proper solution even!)
> and it's not working because they're not virtual,
You usually add `void _dtor()` at the first virtual slot and implement
that function to manually call __xdtor. It's a terrible hack, but it
works.
> when it's my understanding that doing that at all is unsupported - though my
> understanding could certainly be outdated.
Your understand is current, but hopefully it will be out of date soon! :)
More information about the Digitalmars-d
mailing list