Meta:

But is it ever legal to return a local stack-allocated static array from a function in D?

It's legal because in D fixed-size arrays are values. So D copies them (but in in some cases theory it can allocate them in the stack frame of the caller and avoid the copy).


Won't that entail a copy either way?

In the code I've shown I have used "pure static", so the array is allocated statically, not on the stack.

Bye,
bearophile

Reply via email to