Issue ID: 20505
           Summary: [DIP1000] Static array allows to escape refewrences to
                    stack variables
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid, safe
          Severity: normal
          Priority: P1
         Component: dmd

For me this is similar to 17764, but the test case is much more simple.

import std.stdio;

void main () @safe
    auto x = bar();

char[] bar() @safe @nogc
    char[128] a;
    char[][2] arr = [a, a];
    return foo(arr);

char[] foo(scope char[][] arr) @safe @nogc
    return arr[0];

Compiled with:
path/to/dmd -preview=dip1000 -run foo.d
Will print garbage. Tested with v2.090.0 and HEAD
(v2.090.0-beta.1-51-g49dfbe54f, commit of 2020-01-08).


Reply via email to