Skip to content

setindex on SizedArray fails when target array has uninitialised data #1330

@penelopeysm

Description

@penelopeysm
julia> using StaticArrays

julia> v = @SVector zeros(3)
3-element SVector{3, Float64} with indices SOneTo(3):
 0.0
 0.0
 0.0

julia> v2 = similar(v, Real)
3-element SizedVector{3, Real, Vector{Real}} with indices SOneTo(3):
 #undef
 #undef
 #undef

julia> setindex(v2, 1.0, 1)
ERROR: UndefRefError: access to undefined reference
Stacktrace:
 [1] getindex
   @ ./essentials.jl:917 [inlined]
 [2] getindex
   @ ~/.julia/packages/StaticArrays/IZgIP/src/SizedArray.jl:92 [inlined]
 [3] macro expansion
   @ ~/.julia/packages/StaticArrays/IZgIP/src/deque.jl:193 [inlined]
 [4] _setindex
   @ ~/.julia/packages/StaticArrays/IZgIP/src/deque.jl:186 [inlined]
 [5] setindex(a::SizedVector{3, Real, Vector{Real}}, x::Float64, index::Int64)
   @ StaticArrays ~/.julia/packages/StaticArrays/IZgIP/src/deque.jl:185
 [6] top-level scope
   @ REPL[4]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions