Bug 22306 – scope array variable should be stack allocated

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-09-14T16:03:04Z
Last change time
2022-10-18T19:32:35Z
Keywords
pull
Assigned to
No Owner
Creator
Dennis
See also
https://issues.dlang.org/show_bug.cgi?id=13381, https://issues.dlang.org/show_bug.cgi?id=20734

Comments

Comment #0 by dkorpel — 2021-09-14T16:03:04Z
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.
Comment #1 by dlang-bot — 2022-10-14T20:08:33Z
@dkorpel created dlang/dmd pull request #14562 "Fix issue 22306 - scope array variable should be stack allocated" fixing this issue: - Fix issue 22306 - scope array variable should be stack allocated https://github.com/dlang/dmd/pull/14562
Comment #2 by dlang-bot — 2022-10-18T19:32:35Z
dlang/dmd pull request #14562 "Fix issue 22306 - scope array variable should be stack allocated" was merged into master: - 0987a2a95b902d287c4e8efa3628ce4a494b2715 by Dennis Korpel: Fix issue 22306 - scope array variable should be stack allocated https://github.com/dlang/dmd/pull/14562