Fix #23605 - extern(C++) destructor uses wrong ABI on x86 in derived … - #23606
Fix #23605 - extern(C++) destructor uses wrong ABI on x86 in derived …#23606tim-dlang wants to merge 1 commit into
Conversation
|
|
||
| // Destructors, which could be placed in a C++ vtbl, need C++ linkage | ||
| if (ad.isClassDeclaration() && ad.classKind == ClassKind.cpp && ad.ident != Id.ticppdtor) | ||
| sc.linkage = LINK.cpp; |
There was a problem hiding this comment.
Hmm, this looks like user dtors might get their linkage overridden here too. I don't see a way to detect the generated aggrDtor here, or rather, that wouldn't be enough, in case it isn't needed (a single user dtor to call, no fields to destruct and no base dtor to call). So I think this should be handled in buildDtors(), generating an extern(C++) wrapper in that specific case too, as proposed in ldc-developers/ldc#5260 (comment) (the case with a single dtor to call, but no matching linkage).
If overriding the linkage cannot be done there directly, I'd suggest doing it like for the Windows C++ dtor, with an extra scope:
Lines 1131 to 1139 in 6caf6a7
There was a problem hiding this comment.
Hmm, this looks like user dtors might get their linkage overridden here too. I don't see a way to detect the generated aggrDtor here, or rather, that wouldn't be enough, in case it isn't needed (a single user dtor to call, no fields to destruct and no base dtor to call). So I think this should be handled in
buildDtors(), generating anextern(C++)wrapper in that specific case too, as proposed in ldc-developers/ldc#5260 (comment) (the case with a single dtor to call, but no matching linkage).
Yes, this also sets the linkage for the user dtors. The different dtor types can be distinguished using ad.ident. I have excluded the dtor used for the type info with ad.ident != Id.ticppdtor.
Using a new scope is a good idea and would be more consistent with other generated destructors. I can try to do it that way.
…ived class Destructors in a C++ vtbl need C++ linkage.
…class
Destructors in a C++ vtbl need C++ linkage.