https://issues.dlang.org/show_bug.cgi?id=18637
Walter Bright <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #3 from Walter Bright <[email protected]> --- Simplifying the test case: void test() { int i; int*[] a = [&i]; // Error: copying `& i` into allocated memory escapes a reference to local variable `i` } This can be worked around with: void test() { int i; int*[] a = [foo(&i)]; } int* foo(int* p) { return p; } It can be reasonably argued either way whether the original test case should be allowed in @system. I'll argue the workaround makes it obvious what one is doing, and unlikely to do it by accident. It's similar to: int* test() { int i; return &i; } being an error even in @system code. --
