Is it defined behavior to modify `iter` while `for`-looping over it?

This part of the discussion should probably be split off to a new thread, but yeah, the docstring should warn about that too.

julia> v = collect(1:7);

julia> i = collect(1:7);

julia> w = view(v, i);

julia> i[end] = 0;

julia> w[end]
128974949945120

Edit: PR in Document changing view indices after construction as undefined behavior. by GunnarFarneback · Pull Request #59591 · JuliaLang/julia · GitHub

2 Likes