-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Labels
arrays[a, r, r, a, y, s][a, r, r, a, y, s]display and printingAesthetics and correctness of printed representations of objects.Aesthetics and correctness of printed representations of objects.error messagesBetter, more actionable error messagesBetter, more actionable error messagesgood first issueIndicates a good issue for first-time contributors to JuliaIndicates a good issue for first-time contributors to Juliahelp wantedIndicates that a maintainer wants help on an issue or pull requestIndicates that a maintainer wants help on an issue or pull request
Description
Because of how MemoryRefs can represent views and because the MemoryRef itself is not captured in BoundsErrors, we can get confusing errors like this:
julia> x = Memory{Int}([1,2,3,4])
4-element Memory{Int64}:
1
2
3
4
julia> copyto!(x, 3, x, 3, 3)
ERROR: BoundsError: attempt to access MemoryRef{Int64} at index [3]
Stacktrace:
[1] memoryref
@ ./boot.jl:524 [inlined]
[2] unsafe_copyto!
@ ./genericmemory.jl:115 [inlined]
[3] unsafe_copyto!
@ ./genericmemory.jl:139 [inlined]
[4] copyto!(dest::Memory{Int64}, doffs::Int64, src::Memory{Int64}, soffs::Int64, n::Int64)
@ Base ./genericmemory.jl:175
[5] top-level scope
@ REPL[1]:1This example is confusing because one could think that the memory has length 4 so accessing it at index 3 should be fine. What's happening is that a MemoryRef is constructed at an offset and then indexed out of bounds at index 3 when the new MemoryRef only has two indices.
Metadata
Metadata
Assignees
Labels
arrays[a, r, r, a, y, s][a, r, r, a, y, s]display and printingAesthetics and correctness of printed representations of objects.Aesthetics and correctness of printed representations of objects.error messagesBetter, more actionable error messagesBetter, more actionable error messagesgood first issueIndicates a good issue for first-time contributors to JuliaIndicates a good issue for first-time contributors to Juliahelp wantedIndicates that a maintainer wants help on an issue or pull requestIndicates that a maintainer wants help on an issue or pull request