www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20063] New: compiler segfaults on passing templates

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

          Issue ID: 20063
           Summary: compiler segfaults on passing templates expression to
                    lazy val
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ali.akhtarzada gmail.com

import std;

struct S {
    void f(alias fun)() {}
}

auto handleLazily(T)(lazy T expr) {}

void main() {
    class C {}
    S().f!(() => new C())
        .handleLazily;
}

Produced "Segmentation fault (core dumped)"

dmd ver 2.087

LDC produces compiler error: onlineapp.d(12): Error: template instance
`f!(delegate () => new C)` cannot use local __lambda2 as parameter to
non-global template f(alias fun)()

--
Jul 18 2019