Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

false positive: BoundsError on @view on CircularBuffer #564

Open
dpinol opened this issue Aug 28, 2023 · 0 comments
Open

false positive: BoundsError on @view on CircularBuffer #564

dpinol opened this issue Aug 28, 2023 · 0 comments

Comments

@dpinol
Copy link
Contributor

dpinol commented Aug 28, 2023

A false positive is reported by JET 0.8.12 (also in 0.8.14) which did not appear on 0.8.11. Reproducible in julia 1.9.3 & 1.10.0beta3

I attach complete MWE
BoundsCircular.zip

thanks

module BoundsCircular

using Statistics
using DataStructures: CircularBuffer


mutable struct ValuesWindow{T}
    const values::CircularBuffer{T}
end

function it(vw::ValuesWindow)
    v = @view vw.values[1:end]
    return iterate(v)
end

vw = ValuesWindow(CircularBuffer{Float32}(2))
append!(vw.values, [1.0f0, 2.0f0])
v = @view vw.values[1:end]
@info it(vw)


end # module BoundsCircular
julia> using JET; JET.report_package("BoundsCircular")
[toplevel-info] virtualized the context of Main (took 0.001 sec)
[toplevel-info] entered into /home/dani/dev/julia/jet/issues/BoundsCircular/src/BoundsCircular.jl
[ Info: (1.0f0, (Base.OneTo(2), 1))
[toplevel-info]  exited from /home/dani/dev/julia/jet/issues/BoundsCircular/src/BoundsCircular.jl (took 0.03 sec)
[toplevel-info] analyzing from top-level definitions (3/3)
[toplevel-info] analyzed 3 top-level definitions (took 0.502 sec)
═════ 1 possible error found ═════
┌ it(vw::BoundsCircular.ValuesWindow) @ BoundsCircular /home/dani/dev/julia/jet/issues/BoundsCircular/src/BoundsCircular.jl:13
│┌ iterate(A::SubArray{_A, 1, _B, Tuple{UnitRange{Int64}}, false} where {_A, _B}) @ Base ./abstractarray.jl:1220
││┌ iterate(iter::SubArray{T, 1, _B, Tuple{UnitRange{Int64}}, false} where {T<:CartesianIndex, _B<:(Base.ReshapedArray{T, 1, P} where P<:CartesianIndices)}, ::Tuple{Base.OneTo{Int64}}) @ Base.IteratorsMD ./multidimensional.jl:598
│││┌ indexed_iterate(t::Tuple{Base.OneTo{Int64}}, i::Int64, state::Int64) @ Base ./tuple.jl:88
││││ BoundsError: attempt to access Tuple{Base.OneTo{Int64}} at index [2]: Base.getfield(t::Tuple{Base.OneTo{Int64}}, i::Int64)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant