julia
julia copied to clipboard
Bounds check inconsistency in `keepat!`/`deleteat!`
It turns out that bounds checking cannot be programmatically elided in deleteat! and keepat!, but it can be elided in keepat! by starting julia with --check-bounds=no.
MWE may lead to undefined behaviour.
arr = [1,2,3,4,5];
badsub = [2,3,6];
keepat!(copy(arr), badsub);
deleteat!(copy(arr), badsub);
@inbounds keepat!(copy(arr), badsub);
@inbounds deleteat!(copy(arr), badsub);
v1.10.3 and master. All four attempts throw with --check-bounds=auto. The two deleteat! also throw with --check-bounds=no. This could potentially be a performance problem.