Bug 15589 – extern(C++) virtual destructors are not put in vtbl[]
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-01-22T07:55:21Z
Last change time
2018-06-14T07:46:45Z
Assigned to
No Owner
Creator
Walter Bright
Comments
Comment #0 by bugzilla — 2016-01-22T07:55:21Z
A problem with the virtual destructor, as DMD doesn't allocate a vtbl[] slot. To workaround on the D end, replace:
~this() { }
with:
dtor() { }
It's even worse on Linux, where the destructor takes two vtbl[] slots, and so the workaround is:
dtor1() { }
dtor1() { }
Comment #1 by petar.p.kirov — 2016-01-22T10:05:21Z
I guess what you meant to say is that on Linux the workaround is:
void dtor1() { }
void dtor2() { }
Comment #2 by turkeyman — 2016-01-24T23:05:58Z
Just to be clear, this is only for classes with a virtual destructor in the base?
In the case where linux needs 2 destructors, what are they each for? How should they each be defined?
Comment #3 by turkeyman — 2016-01-26T02:48:08Z
I'm noticing a problem with constructors. Is this related?
'extern(C++) this() {}' doesn't seem to emit a C++ constructor, it emit's a call to Class::__ctor, which isn't what C++ calls constructors.
Do I need to duplicate constructors on the D side?
Comment #4 by github-bugzilla — 2018-06-07T09:17:13Z