[Issue 23111] New: stack-allocated array escapes in @safe code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 16 04:05:01 UTC 2022


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

--


More information about the Digitalmars-d-bugs mailing list