File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -90,8 +90,17 @@ tags[:unionall] = d -> UnionAll(d[:var], d[:body])
90
90
lower (x:: Vector{Any} ) = copy (x)
91
91
lower (x:: Vector{UInt8} ) = x
92
92
93
- reinterpret_ (:: Type{T} , x) where T =
94
- T[_x for _x in reinterpret (T, x)]
93
+ function reinterpret_ (:: Type{T} , x) where T
94
+ r = reinterpret (T, x)
95
+ if r isa Base. ReinterpretArray && ! (r. readable)
96
+ # type mapping was successful, but the array is not readable due to padding
97
+ # in that case make r a type-cast view of the original array
98
+ # the data might not be restorable on a different machine with different padding or with a different version of Julia
99
+ @warn " storing structure with padding, data might not be restorable"
100
+ r = unsafe_wrap (Vector{T}, Ptr {T} (pointer (x)), sizeof (x))
101
+ end
102
+ T[_x for _x in r]
103
+ end
95
104
96
105
function lower (x:: Array )
97
106
ndims (x) == 1 && ! isbitstype (eltype (x)) && return Any[x... ]
You can’t perform that action at this time.
0 commit comments