[Issue 17049] New: [scope] class references are not escape checked like pointers
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Dec 31 08:23:37 PST 2016
https://issues.dlang.org/show_bug.cgi?id=17049
Issue ID: 17049
Summary: [scope] class references are not escape checked like
pointers
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: code at dawg.eu
cat > bug.d << CODE
version (all) // broken for class refs
class P;
else
alias P = int*; // works for int pointers
struct S
{
@safe P get() return scope;
}
P escape() @safe
{
S s;
P p = s.get();
return p;
}
CODE
----
dmd -c -o- bug -transition=safe -de
----
Should fail to compile and report `scope variable p may not be returned`.
Tested with v2.073.0-scope-e46873f (dmd-scope-2016-12-27 preview build).
--
More information about the Digitalmars-d-bugs
mailing list