Skip to content

Commit d1a0879

Browse files
committed
Fix and test #23629
Ensure bounds are checked over trailing zero dimensions
1 parent f65c403 commit d1a0879

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

base/deprecated.jl

+2-3
Original file line numberDiff line numberDiff line change
@@ -1753,9 +1753,8 @@ end
17531753
# TODO: Re-enable the disabled tests marked PLI
17541754
# On the Julia side, this definition will gracefully supercede the new behavior (already coded)
17551755
@inline function checkbounds_indices(::Type{Bool}, IA::Tuple{Any,Vararg{Any}}, ::Tuple{})
1756-
if any(x->unsafe_length(x)!=1, IA)
1757-
_depwarn_for_trailing_indices(IA)
1758-
end
1756+
any(x->unsafe_length(x)==0, IA) && return false
1757+
any(x->unsafe_length(x)!=1, IA) && return _depwarn_for_trailing_indices(IA)
17591758
return true
17601759
end
17611760
function _depwarn_for_trailing_indices(n::Integer) # Called by the C boundscheck

test/arrayops.jl

+6
Original file line numberDiff line numberDiff line change
@@ -2229,3 +2229,9 @@ let a = Vector{Int}[[1]],
22292229
@test eltype([a;b]) == Vector{Float64}
22302230
@test eltype([a;c]) == Vector
22312231
end
2232+
2233+
# Issue #23629
2234+
@testset "issue 23629" begin
2235+
@test_throws BoundsError zeros(2,3,0)[2,3]
2236+
@test_throws BoundsError checkbounds(zeros(2,3,0), 2, 3)
2237+
end

0 commit comments

Comments
 (0)