Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <jacob-carlborg@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
52 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/test15373.d(21): Error: Runtime type information is not supported for `extern(C++)` classes | ||
--- | ||
*/ | ||
|
||
// https://issues.dlang.org/show_bug.cgi?id=15373 | ||
|
||
// Using `typeid` on an `extern(C++) class` type is ok as it is evaluated at compile-time | ||
// See test/runnable/test15373.d | ||
|
||
// Using `typeid` on an `extern(C++) class` instance is not ok because `extern(C++) class` | ||
// instances are not rooted in `Object` | ||
|
||
extern(C++) class C { } | ||
|
||
void foo() | ||
{ | ||
C c = new C(); | ||
auto ti = typeid(c); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// https://issues.dlang.org/show_bug.cgi?id=15373 | ||
|
||
// Using `typeid` on an `extern(C++) class` type is fine as it is evaluated at compile-time | ||
|
||
// Using `typeid` on an `extern(C++) class` instance is not ok because `extern(C++) class` | ||
// instances are not rooted in `Object`. See test/fail_compilation/test15373.d | ||
|
||
extern(C++) class C | ||
{ } | ||
|
||
void main() | ||
{ | ||
auto Cti = typeid(C); | ||
assert(Cti.name == "test15373.C"); | ||
} |