#Arrays getting copied to the stack

1 messages · Page 1 of 1 (latest)

tulip tide
#

One screenshot is 0.10.0 and the other is master. In 0.10.0 debug mode it will copy a whole non-local array to the stack even if you're just dereferencing one index. I see that's been changed in master so it's a solved problem, I guess.

I just wanted to ask if there are any other gotchas I should watch out for. I'm here from C++ to avoid constructors.

unborn axle
#

arrays are always on the stack

#

but the fact is copying itself after one deref is worrying

silent hawk
#

I see that's been changed in master so it's a solved problem, I guess.
It's not entirely solved. There is still some corner cases where it does still copy things around: https://github.com/ziglang/zig/issues/15685
But it only happens in debug and there is a workaround.