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.
Comment #2 by slavo5150 — 2018-07-29T06:22:51Z
Comment #3 by github-bugzilla — 2018-07-30T18:51:57Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/76d4781b8a26ed9655b190a9e18b8c030e24bc74 Fix Issue 15373 - Segfault when using typeid on extern(C++) class with virtual functions https://github.com/dlang/dmd/commit/2de932606a7577aef3fc35a0e1f780b48abb097f Merge pull request #8526 from JinShil/fix_15373 Fix Issue 15373 - Segfault when using typeid on extern(C++) class with virtual functions merged-on-behalf-of: Jacob Carlborg <[email protected]>