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

          Issue ID: 14807
           Summary: unnecessary closure allocation for function literal in
                    compile time test
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

cat > bug.d << CODE
void foo(int a) @nogc
{
    static if (__traits(compiles, { a = 2; }))
    {}
}
CODE

bug.d(1): Error: function bug.foo @nogc function allocates a closure with the
GC

----

Not sure if it's easy to detect the context of a function literal and see that
it can never be called.

--

Reply via email to