Skip to content

Commit 641ae2c

Browse files
JeffBezansonKristofferC
authored andcommitted
fix #52025, re-allow all implicit pointer casts in cconvert for Array (#53659)
fix #52025 (cherry picked from commit f9e08f7)
1 parent fd9c49c commit 641ae2c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

base/refpointer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ if is_primary_base_module
171171
Ref(x::AbstractArray, i::Integer) = RefArray(x, i)
172172
end
173173

174-
cconvert(::Type{Ptr{P}}, a::Array{P}) where {P<:Union{Ptr,Cwstring,Cstring}} = getfield(a, :ref)
175-
cconvert(::Type{Ref{P}}, a::Array{P}) where {P<:Union{Ptr,Cwstring,Cstring}} = getfield(a, :ref)
174+
cconvert(::Type{Ptr{P}}, a::Array{<:Union{Ptr,Cwstring,Cstring}}) where {P<:Union{Ptr,Cwstring,Cstring}} = getfield(a, :ref)
175+
cconvert(::Type{Ref{P}}, a::Array{<:Union{Ptr,Cwstring,Cstring}}) where {P<:Union{Ptr,Cwstring,Cstring}} = getfield(a, :ref)
176176
cconvert(::Type{Ptr{P}}, a::Array) where {P<:Union{Ptr,Cwstring,Cstring}} = Ref{P}(a)
177177
cconvert(::Type{Ref{P}}, a::Array) where {P<:Union{Ptr,Cwstring,Cstring}} = Ref{P}(a)
178178

test/ccall.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,3 +1934,6 @@ end
19341934
end
19351935
@test_throws "could not load symbol \"test\"" somefunction_not_found_libc()
19361936
end
1937+
1938+
# issue #52025
1939+
@test Base.unsafe_convert(Ptr{Ptr{Cchar}}, Base.cconvert(Ptr{Ptr{Cchar}}, map(pointer, ["ab"]))) isa Ptr{Ptr{Cchar}}

0 commit comments

Comments
 (0)