[Issue 21690] Unable to dynamic cast extern(C++) classes
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 8 23:38:05 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21690
kinke <kinke at gmx.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kinke at gmx.net
--- Comment #1 from kinke <kinke at gmx.net> ---
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.
So while getting proper dynamic casts working is probably quite hard, we could
probably disallow downcasts like this and require an explicit static cast
(`cast(CC) cast(void*) ca`)?
--
More information about the Digitalmars-d-bugs
mailing list