www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15835] New: Segfault with typeid call from lazy argument

https://issues.dlang.org/show_bug.cgi?id=15835

          Issue ID: 15835
           Summary: Segfault with typeid call from lazy argument
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: code klickverbot.at

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.


(https://github.com/ldc-developers/ldc/issues/1369).

--
Mar 26 2016