Skip to content

Commit

Permalink
Fix typo in unsafe_wrap method (#54582)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobnissen authored May 27, 2024
1 parent a1e1a3a commit 58ed793
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/pointer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ end
function unsafe_wrap(::Union{Type{GenericMemory{kind,<:Any,Core.CPU}},Type{GenericMemory{kind,T,Core.CPU}}},
p::Ptr{T}, dims::Tuple{Int}; own::Bool = false) where {kind,T}
ccall(:jl_ptr_to_genericmemory, Ref{GenericMemory{kind,T,Core.CPU}},
(Any, Ptr{Cvoid}, Csize_t, Cint), GenericMemory{kind,T,Core.CPU}, p, dim[1], own)
(Any, Ptr{Cvoid}, Csize_t, Cint), GenericMemory{kind,T,Core.CPU}, p, dims[1], own)
end
function unsafe_wrap(::Union{Type{GenericMemory{kind,<:Any,Core.CPU}},Type{GenericMemory{kind,T,Core.CPU}}},
p::Ptr{T}, d::Integer; own::Bool = false) where {kind,T}
Expand Down
10 changes: 10 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6251,6 +6251,16 @@ let
@test_throws ArgumentError unsafe_wrap(Array, convert(Ptr{Union{Int, Nothing}}, pointer(A5)), 6)
end

# More unsafe_wrap
let
a = [1, 2, 3]
GC.@preserve a begin
m = unsafe_wrap(Memory{Int}, pointer(a), (3,))
@test m == a
@test m isa Memory{Int}
end
end

# copyto!
A23567 = Vector{Union{Float64, Nothing}}(undef, 5)
B23567 = collect(Union{Float64, Nothing}, 1.0:3.0)
Expand Down

2 comments on commit 58ed793

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

Please sign in to comment.