www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17428] New: [scope] class field assignment allows to escape

https://issues.dlang.org/show_bug.cgi?id=17428

          Issue ID: 17428
           Summary: [scope] class field assignment allows to escape scope
                    parameters
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: safe
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

cat > bug.d << CODE
class Klazz
{
    void set(scope int* p)  safe
    {
        _p = p; // should error, works for structs
    }

    int* _p;
}

Klazz test()  safe
{
    int a;
    auto p = new Klazz();
    p.set(&a);
    return p;
}
CODE

dmd -c bug -dip1000

--
May 24