[Issue 13381] New: One case of array literal that can be stack-allocated

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Aug 27 02:39:19 PDT 2014


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

          Issue ID: 13381
           Summary: One case of array literal that can be stack-allocated
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: bearophile_hugs at eml.cc

I think this is an array literal usage pattern where the compiler can allocate
the array on the stack, allowing the function foo to be @nogc:


void foo(in uint[] a) @nogc {
    if (a == [1]) {}
}
void main() {}


Currently dmd 2.067alpha gives:

temp.d(2,14): Error: array literal in @nogc function foo may cause GC
allocation

--


More information about the Digitalmars-d-bugs mailing list