[Issue 19573] New: usage of delegate literals at compile-time allocates closure at run-time

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 10 14:29:27 UTC 2019


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

          Issue ID: 19573
           Summary: usage of delegate literals at compile-time allocates
                    closure at run-time
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: regnellday at protonmail.com

Minimal example:
---
void main()
{
    int i;
    static assert(isCallable!(() => i)); // allocates
    static assert(is(typeof(() => i))); // ok
}

template isCallable(T...)
{
    enum bool isCallable = true;
}
---
dmd -vcg-ast output:
---
import object;
void main()
{
        int i = 0;
        return 0;
}
enum bool isCallable(T...) = true;
isCallable!(delegate () => i)
{
        enum bool isCallable = true;

}
---

--


More information about the Digitalmars-d-bugs mailing list