[Issue 18788] static arrays with a length specified at runtime should dynamically allocate on the stack

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 22 00:25:22 UTC 2018


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

--- Comment #5 from Mike Franklin <slavo5150 at yahoo.com> ---
Another way of achieving the same result would be to make a `scope`d dynamic
array allocate on the stack

---
class C { }

void main()
{
    scope C c = new C();       // `c` is allocated on the stack
    scope int[] i = [1, 2, 3]; // `i` is inconsistently allocated on the heap
}

I think this should be consistent between classes and dynamic arrays; `i`
should be allocated on the stack, and appending to it should allocate
`realloc`ate it on the stack.

--


More information about the Digitalmars-d-bugs mailing list