[Issue 18128] New: [scope] escaping reference to class allocated on the stack
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Dec 25 20:24:16 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=18128
Issue ID: 18128
Summary: [scope] escaping reference to class allocated on the
stack
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: bugzilla at digitalmars.com
class A {
int i;
}
void inc(A a) @safe {
a.i += 1; // Line 6
}
auto makeA() @safe { // Line 9
import std.algorithm : move;
scope a = new A(); // allocates object on the stack instead of the heap
return move(a); // should give an error
}
void main() @safe {
auto a = makeA();
a.inc(); // Line 17
}
--
More information about the Digitalmars-d-bugs
mailing list