www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17049] New: [scope] class references are not escape checked


          Issue ID: 17049
           Summary: [scope] class references are not escape checked like
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

cat > bug.d << CODE
version (all) // broken for class refs
    class P;
    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;
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).

Dec 31 2016