https://issues.dlang.org/show_bug.cgi?id=24754
--- Comment #12 from Nick Treleaven <[email protected]> --- (In reply to Dennis from comment #8) > Reduces to: > > ```D > void main() @safe > { > foreach(ref e; new int[1]) > int* f = &e; > } > ``` The compiler doesn't know (without optimization or -dip1000) that the program is equivalent to that. It doesn't know below that `f` doesn't escape the scope of foobar somehow. @safe void foobar() { int* f; foreach(ref e; foo) f = &e; } So it seems counter-intuitive to the way D's semantic analysis works to allow this case without -dip1000. --
