Skip to content

Commit

Permalink
Fix and test #23629
Browse files Browse the repository at this point in the history
  • Loading branch information
mbauman committed Sep 8, 2017
1 parent d216f87 commit f9826c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 2 additions & 3 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1728,9 +1728,8 @@ end
# issue #14470
# This definition will gracefully supercede the real definition until deprecations are removed
@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
2 changes: 1 addition & 1 deletion src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ static Value *emit_array_nd_index(
if (bc) {
// We have already emitted a bounds check for each index except for
// the last one which we therefore have to do here.
if (nidxs == 1 && nd > 1) {
if (nidxs == 1) {
// Linear indexing: Check against the entire linear span of the array
Value *alen = emit_arraylen(ctx, ainfo, ex);
ctx.builder.CreateCondBr(ctx.builder.CreateICmpULT(i, alen), endBB, failBB);
Expand Down
6 changes: 6 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2210,3 +2210,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 f9826c5

Please sign in to comment.