xxxxxxxxxx
:
import std.stdio: writeln;
void f(ref int x, ref int[] arr) {
x += 1; // this happens on arr[2]
arr ~= new int[900000]; // array is relocated
x += 1; // this now writes to random memory and will not be reflected on arr
}
void main() {
auto arr = new int[10];
f(arr[2], arr);
writeln(arr[0..10]);
}