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

ReinterpretArray and nested structure padding #29605

Open
chethega opened this issue Oct 11, 2018 · 3 comments
Open

ReinterpretArray and nested structure padding #29605

chethega opened this issue Oct 11, 2018 · 3 comments

Comments

@chethega
Copy link
Contributor

Unfortunately the current tests for structure padding #25908 do not recurse down the type hierarchy, i.e. #27877 is incomplete. Sorry, I should have thought about that possibility when @Keno first introduced the padding machinery :(

julia> struct padded
       a::Bool
       b::UInt32
       end

julia> struct wrapped
       x::padded
       end

julia> a=collect(1:2); r=reinterpret(wrapped, a); r[2]=r[1];

julia> a
2-element Array{Int64,1}:
        1
 16541441
@Keno
Copy link
Member

Keno commented Oct 11, 2018

yep, this was discussed and we should extend the padding mechanism to handle this, but we considered just getting the simple thing in first better than nothing.

@BioTurboNick
Copy link
Contributor

BioTurboNick commented Nov 13, 2023

The padding checks in #47116 properly recurses nested structures, but I don't believe the array reinterpret code is using it right now. It does, just not when it's being created.

However, the example in the OP currently results in a padding error during setindex! on 1.10-rc2.

@BioTurboNick
Copy link
Contributor

I think this is by design then - the example ReinterpretArray is deemed readable but not writable, because it's reading the padding properly. So this issue can probably be closed.

julia> dump(r)
Base.ReinterpretArray{wrapped, 1, Int64, Vector{Int64}, false}
  parent: Array{Int64}((2,)) [1, 2]
  readable: Bool true
  writable: Bool false

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

3 participants