Bug 6713 – Segfault with typeid of an alias

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-09-22T03:44:00Z
Last change time
2012-01-28T15:25:47Z
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2011-09-22T03:44:21Z
From the test suite, test1() in testtypeid.d, if 'typedef' is replaced by 'alias', a runtime segfault occurs. It works if typedef is used instead. import std.stdio; class ABC { } alias ABC DEF; // typedef ABC DEF; is OK. TypeInfo foo() { ABC c; return typeid(DEF); } void main() { TypeInfo ti = foo(); TypeInfo_Typedef td = cast(TypeInfo_Typedef)ti; assert(td); ti = td.base; TypeInfo_Class tc = cast(TypeInfo_Class)ti; assert(tc); printf("%.*s\n", tc.info.name.length, tc.info.name.ptr); assert(tc.info.name == "testtypeid.ABC"); }
Comment #1 by bugzilla — 2012-01-28T15:25:47Z
The problem is this line: TypeInfo_Typedef td = cast(TypeInfo_Typedef)ti; ti is a TypeInfo_Class. There is no TypeInfo_Alias, and an alias isn't a TypeInfo_Typedef.