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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 21 13:07:34 UTC 2018


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

--- Comment #3 from anonymous4 <dfj1esp02 at sneakemail.com> ---
Reduced:

@safe:

struct A(alias fun)
{
    int[] r;
    this(int[] q){r=q;}
}

template m(alias fun)
{
    auto m(int[] r)
    {
        return A!fun(r);
    }
}

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

void main() {
  auto a=foo();
}

--


More information about the Digitalmars-d-bugs mailing list