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: [email protected]
Reporter: [email protected]
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
```
--