[Issue 21690] Unable to dynamic cast extern(C++) classes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 9 00:31:59 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21690

--- Comment #3 from thomas.bockman at gmail.com ---
(In reply to kinke from comment #1)
> The C++ vtable emitted by D does not contain any pointer to any typeinfo
> AFAIK. Of course we don't generate the C++ typeinfo anyway, but we do
> generate the D one (for use with the D GC). At least some C++
> implementations store the (C++) typeinfo pointer at vtbl index -1. But then
> again, when we are confronted with some C++ class ref, we have no idea
> whether it was instantiated on the D side or C++ side and so which vtable
> its vptr points to.

Does that mean that passing a D-initialized extern(C++) class instance to C++
code breaks dynamic casting on the C++ side, too? If so, that is a critical
issue, as well.

Given that all current D compilers are also C++ compilers, would it be possible
to just auto-generate an actual C++ function that performs the dynamic_cast<>,
and then call (and hopefully inline) that function from the D side?

--


More information about the Digitalmars-d-bugs mailing list