Bug 1811 – TypeInfo usage leads to seg fault at runtime

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2008-01-30T15:20:00Z
Last change time
2015-06-09T01:14:30Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
kamm-removethis

Comments

Comment #0 by kamm-removethis — 2008-01-30T15:20:12Z
The code import std.stdio; class Base { int foo() { return 0; } } class Sub : Base { override int foo() { return 0; } } void main() { auto t1 = typeid(typeof(Sub.foo)); auto t2 = typeid(typeof(Base.foo)); // <- comment to fix t1.tsize(); // crash } compiles fine, but crashes when run.
Comment #1 by kamm-removethis — 2008-01-30T15:26:43Z
Note that classes or virtual functions are not responsible. The same behaviour is shown by import std.stdio; void main() { int foo() { return 0; } int bar() { return 0; } auto t1 = typeid(typeof(foo)); auto t2 = typeid(typeof(bar)); t1.tsize(); // crash }
Comment #2 by kamm-removethis — 2008-01-30T15:32:24Z
I think it is related to 1522, as I get a multiple definition linker error for _D12TypeInfo_FZi6__initZ when feeding the code to DMD 1.021.
Comment #3 by bugzilla — 2008-03-04T23:48:15Z
Works in DMD 2.011.
Comment #4 by kamm-removethis — 2008-03-05T02:25:13Z
Both snippets still produce segmentation faults for me using a fresh DMD 2.011 and linux.
Comment #5 by aifgi90 — 2010-01-27T07:02:48Z
Works in DMD 1.055 and DMD 2.039