www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23111] New: stack-allocated array escapes in safe code


          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: nobody puremagic.com
          Reporter: su+dlangissues angel-island.zone

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.

May 15 2022