Skip to content

Commit

Permalink
Fix and test #23629
Browse files Browse the repository at this point in the history
Ensure bounds are checked over trailing zero dimensions
  • Loading branch information
mbauman committed Sep 19, 2017
1 parent f65c403 commit d1a0879
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 2 additions & 3 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1753,9 +1753,8 @@ end
# TODO: Re-enable the disabled tests marked PLI
# On the Julia side, this definition will gracefully supercede the new behavior (already coded)
@inline function checkbounds_indices(::Type{Bool}, IA::Tuple{Any,Vararg{Any}}, ::Tuple{})
if any(x->unsafe_length(x)!=1, IA)
_depwarn_for_trailing_indices(IA)
end
any(x->unsafe_length(x)==0, IA) && return false
any(x->unsafe_length(x)!=1, IA) && return _depwarn_for_trailing_indices(IA)
return true
end
function _depwarn_for_trailing_indices(n::Integer) # Called by the C boundscheck
Expand Down
6 changes: 6 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2229,3 +2229,9 @@ let a = Vector{Int}[[1]],
@test eltype([a;b]) == Vector{Float64}
@test eltype([a;c]) == Vector
end

# Issue #23629
@testset "issue 23629" begin
@test_throws BoundsError zeros(2,3,0)[2,3]
@test_throws BoundsError checkbounds(zeros(2,3,0), 2, 3)
end

0 comments on commit d1a0879

Please sign in to comment.