Bug 15373 – Segfault when using typeid on extern(C++) class with virtual functions
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-11-22T08:44:52Z
Last change time
2018-07-30T18:51:58Z
Keywords
accepts-invalid, C++, pull
Assigned to
No Owner
Creator
Jakob Ovrum
Comments
Comment #0 by jakobovrum — 2015-11-22T08:44:52Z
----
extern(C++) interface I
{
void foo();
}
extern(C++) class C : I
{
override void foo() {}
}
void main()
{
import std.stdio;
writeln(typeid(new C)); // segfault
}
----
This seems like it should be statically disallowed. Any type with an extern(C++) type in its inheritance hierarchy should be disallowed in typeid(). I don't know if extern(C++) classes can implement D interfaces, but it should at least return null in such cases.
Comment #1 by dfj1esp02 — 2017-07-10T16:52:01Z
Also don't generate TypeInfo for C++ classes, it doesn't look useful.