www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22306] New: scope array variable should be stack allocated

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

          Issue ID: 22306
           Summary: scope array variable should be stack allocated
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dkorpel live.nl

While this  nogc code currently gives an error, the array could be allocated on
the stack:
```
void main()  nogc {
    scope int[] a = new int[10];
    scope int[] a = [1, 2, 3];
}
```
It's already done for `scope` classes and array literals passed to scope
parameters. It has been brought up before
(https://github.com/dlang/dmd/pull/11039#issuecomment-613518685) but I don't
see a bugzilla issue for it yet.

--
Sep 14