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
Commit pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/41151beba9fdd3a649729f2fae1ef51fd71c725e Fix issue 15589 - extern(C++) virtual destructors are not put in vtbl[]
Comment #5 by github-bugzilla — 2018-06-14T07:46:45Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/ab0a7bf76dbf0a02e826a1a9b54f9d813c7a114a fix issue 15589 - cleanup after PR #8277 fix mangling, add shim functions for vtbl and type info, fix dtor inside Attribdeclaration, use Id-pool https://github.com/dlang/dmd/commit/d08e0fb3bff6767bd28516f53393083d86f63045 Merge pull request #8349 from rainers/issue15589 fix issue 15589 - cleanup/improve PR #8277 - C++ dtors in vtbl merged-on-behalf-of: Walter Bright <[email protected]>