Bug 15835 – Segfault with typeid call from lazy argument
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-03-26T22:54:00Z
Last change time
2016-10-01T11:45:15Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2016-03-26T22:54:13Z
This program segfaults using both DMD 2.070 and latest Git master (2d1f4f6):
---
extern(C) int printf(const char*, ...);
class A {}
void fun2() {
auto symbol = new A;
fun3(fun4(typeid(symbol)));
}
string fun4(ClassInfo t) {
return t.name;
}
void fun3(lazy const(char)[] c) {
printf("%.*s\n", c.length, c.ptr);
}
void main() {
fun2();
}
---
The issue seems to be that `symbol` is not added to the list of closure variables in fun2, i.e. is not part of the nested context as expected during codegen for the implicit lazy delegate.
Reported by Timothee Cour as LDC issue #1369 (https://github.com/ldc-developers/ldc/issues/1369).