[Issue 19881] New: Escaping reference to local through return scope with -dip1000 and @safe
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu May 16 22:10:47 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19881
Issue ID: 19881
Summary: Escaping reference to local through return scope with
-dip1000 and @safe
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: simen.kjaras at gmail.com
@safe int* fun(return scope int* input) {
int local = 123;
input = &local; // This line shouldn't compile
return input;
}
@safe void main() {
import std.stdio;
int* p;
p = fun(p);
(*p).writeln; // 123
(*p).writeln; // Random garbage
}
--
More information about the Digitalmars-d-bugs
mailing list