On Monday, 21 October 2013 at 21:07:46 UTC, Iain Buclaw wrote:
But yes. I think a GC memcopy should be occuring, as dynamic
arrays
aren't passed by value, so are expected to last the lifetime of
the
reference to the address.
This doesn't produce a heap copy (neither according to the spec
nor to actual DMD/LDC behaviour):
---
void foo() {
int[3] a;
int[] b = a;
}
---
Thus, your example will not copy any data either, as due to
associativity, it is equivalent to an assignment to y followed by
an assignment of y to x. x simply is a slice of the
stack-allocated static array.
David