fix #23262 - [REG v2.113.0-beta.1] ICE when trying to cast a class instance to a C++ interface#23263
fix #23262 - [REG v2.113.0-beta.1] ICE when trying to cast a class instance to a C++ interface#23263rainers wants to merge 1 commit into
Conversation
…ss instance to a C++ interface no need to exclude C++ classes/interfaces from runtime cast target
|
Thanks for your pull request, @rainers! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
|
| int funCpp(); | ||
| } | ||
|
|
||
| class class23262 : Object, iface23262 |
There was a problem hiding this comment.
does inhering from a D class and a C++ interface simultaneously even make sense?
There was a problem hiding this comment.
Sure, I use it in Visual D for COM classes all the time. That's where I triggered the issue.
| int offset; | ||
| if ((cdto.isBaseOf(cdfrom, &offset) && offset != ClassDeclaration.OFFSET_RUNTIME) | ||
| || cdfrom.classKind == ClassKind.cpp || cdto.classKind == ClassKind.cpp) | ||
| || cdfrom.classKind == ClassKind.cpp) |
There was a problem hiding this comment.
Both are needed as casting between D<->C++ classes results in a null result.
There was a problem hiding this comment.
For example, breaking this test
https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gdc.dg/Wcastresult1.d
There was a problem hiding this comment.
Both are needed as casting between D<->C++ classes results in a null result.
Why is this necessary? The D class has full runtime typeinfo available, including C++ interfaces. Also, this used to work up to 2.112.
There was a problem hiding this comment.
I just tested this with the latest GDC version I could easily get hold of (gdc-12), and it indeed returns null from the cast. It behaves differently than all the released versions of DMD and LDC that succeed doing the cast to the C++ interface, so I think it should rather be fixed in GDC, too.
no need to exclude C++ classes/interfaces from runtime cast target