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

          Issue ID: 23111
           Summary: stack-allocated array escapes in @safe code
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

the following code escapes a stack-allocated array, making it unsafe. 

auto foo() @nogc nothrow pure @safe
{
    import std.array : staticArray;
    import std.algorithm : map;

    auto test = [1, 2, 3].staticArray;
    return test[].map!(x => x);
}

when run with -preview=dip1000, it correctly fails to compile.

--

Reply via email to