[Issue 17388] New: [DIP1000] no escape analysis for auto return scope members

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue May 9 11:10:13 PDT 2017


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

          Issue ID: 17388
           Summary: [DIP1000] no escape analysis for auto return scope
                    members
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: per.nordlow at gmail.com

A file named `test_scope.d` containing

@safe pure nothrow @nogc:

struct S
{
    @safe pure nothrow @nogc
    inout(int)[] opSlice() inout return scope
    {
        return x[];
    }
    int[4] x;
}

int[] f()
{
    S s;
    return s[];
}

compiled with -dip1000 correctly errors as

test_scope.d(16,13): Error: escaping reference to local variable s

but if return type of `opSlice` is changed to `auto` the compiler acccepts it
which is wrong.

--


More information about the Digitalmars-d-bugs mailing list