May 16, 2019 [Issue 19881] New: Escaping reference to local through return scope with -dip1000 and @safe | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: simen.kjaras@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 } -- |
Copyright © 1999-2021 by the D Language Foundation