JuliaArrays / JuliaArrays/StaticArrays.jl

Failure to reinterpret SMatrix

Open
#1,201 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
844
Forks
159
Avg merge
3d 21h
Merged PRs (30d)
3

Description

Is this expected behavior? Tested on StaticArrays@v1.6.3.

using StaticArrays

# This gives a surprising error:
A = zeros(SMatrix{3,3,Float64}, 2, 3)
reinterpret(reshape, Float64, A) # ERROR: ArgumentError: cannot reinterpret `SMatrix{3, 3, Float64}` as `Float64`, type `SMatrix{3, 3, Float64}` is not a bits type

# However, it seems like `SMatrix{3, 3, Float64}` is indeed `isbits`
@assert isbits(A[1,1])

# And reinterpreting an `SVector` is fine
B = zeros(SVector{3,Float64}, 4)
reinterpret(reshape, Float64, B)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Julia snippets from the issue with StaticArrays@v1.6.3, comparing reinterpret behavior for SMatrix and SVector. Trace the entry point handling reinterpret of SMatrix values and determine the expected outcome; done when the discrepancy is resolved or its expected behavior is clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.