Skip to content

getindex too relaxed on reinterpreted array #58232

@Moelf

Description

@Moelf
julia> a=[1,2,3]
3-element Vector{Int64}:
 1
 2
 3

julia> a[]
ERROR: BoundsError: attempt to access 3-element Vector{Int64} at index []
Stacktrace:
 [1] throw_boundserror(A::Vector{Int64}, I::Tuple{})
   @ Base ./essentials.jl:14
 [2] checkbounds
   @ ./abstractarray.jl:699 [inlined]

julia> reinterpret(UInt8, a)[]
0x01

the last line should error as well

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]designDesign of APIs or of the language itself

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions