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).
Comment #1 by k.hara.pg — 2016-03-27T16:01:14Z
Comment #2 by github-bugzilla — 2016-03-28T06:28:59Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/71294c1f4fdfad8d945b5e423e3c1ed02f30409d fix Issue 15835 - Segfault with typeid call from lazy argument https://github.com/D-Programming-Language/dmd/commit/39d6bfade540805b32282d6b542d7af8b126ad05 Merge pull request #5585 from 9rnsr/fix15835 Issue 15835 - Segfault with typeid call from lazy argument
Comment #3 by github-bugzilla — 2016-10-01T11:45:15Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/71294c1f4fdfad8d945b5e423e3c1ed02f30409d fix Issue 15835 - Segfault with typeid call from lazy argument https://github.com/dlang/dmd/commit/39d6bfade540805b32282d6b542d7af8b126ad05 Merge pull request #5585 from 9rnsr/fix15835