[Issue 19175] New: @safe code can escape local array references

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Aug 17 07:12:40 UTC 2018


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

          Issue ID: 19175
           Summary: @safe code can escape local array references
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: peter.alexander.au at gmail.com

--------
import std.algorithm, std.stdio;

@safe:

auto foo() {
  int[6] xs = [0, 1, 2, 3, 4, 5];
  return xs[].map!(x => x);
}

void main() {
  writeln(foo());
}
--------

Observed: this compiles and (for me) prints [0, 0, -2132056872, 22008, 0, 0].

Expected: fail to compile with error about the escaped local reference.

--


More information about the Digitalmars-d-bugs mailing list