October 12 [Issue 24806] New: Allocate a struct by new on stack with scope | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24806 Issue ID: 24806 Summary: Allocate a struct by new on stack with scope Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: alphaglosined@gmail.com A nice optimization to have is to allocate memory on the stack when it is scope. This is applied for classes, but not structs. https://dlang.org/spec/attribute.html#scope-class-var ```d struct S { } scope s = new S; // heap allocated ``` -- |
Copyright © 1999-2021 by the D Language Foundation