[Issue 17049] [scope] class references are not escape checked like pointers

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Feb 24 14:42:51 PST 2017


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

--- Comment #4 from Martin Nowak <code at dawg.eu> ---
There is a difference from member functions to free function.

static @safe S* get2(return ref scope S _this)
{
    return &_this;
}

struct S
{
    @safe S* get1() return scope
    {
        return &this;
    }
}

S* escape() @safe
{
    S s;
    auto ps1 = s.get1();
    auto ps2 = s.get2();
    return ps1; // works
    // return ps2; // doesn't work
}

--


More information about the Digitalmars-d-bugs mailing list