Skip to content

Commit 8aa480a

Browse files
committed
Use unsafe_convert instead of pointer
1 parent 7d1cf61 commit 8aa480a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

stdlib/LinearAlgebra/src/adjtrans.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ Base.strides(A::Transpose{<:Any, <:StridedVector}) = (stride(A.parent, 2), strid
193193
Base.strides(A::Adjoint{<:Real, <:StridedMatrix}) = reverse(strides(A.parent))
194194
Base.strides(A::Transpose{<:Any, <:StridedMatrix}) = reverse(strides(A.parent))
195195

196-
Base.pointer(A::Adjoint{<:Real, <:Union{StridedVector,StridedMatrix}}) = pointer(A.parent)
197-
Base.pointer(A::Transpose{<:Any, <:Union{StridedVector,StridedMatrix}}) = pointer(A.parent)
196+
Base.unsafe_convert(::Type{Ptr{T}}, A::Adjoint{<:Real, <:StridedVecOrMat}) where {T} = Base.unsafe_convert(Ptr{T}, A.parent)
197+
Base.unsafe_convert(::Type{Ptr{T}}, A::Transpose{<:Any, <:StridedVecOrMat}) where {T} = Base.unsafe_convert(Ptr{T}, A.parent)
198198

199199
# for vectors, the semantics of the wrapped and unwrapped types differ
200200
# so attempt to maintain both the parent and wrapper type insofar as possible

stdlib/LinearAlgebra/test/adjtrans.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,10 @@ end
501501
@test strides(Transpose(rand(3, 2) .+ rand(3, 2).*im)) == (3, 1)
502502

503503
C = rand(3) .+ rand(3).*im
504-
@test_throws MethodError pointer(Adjoint(C))
504+
@test_throws ErrorException pointer(Adjoint(C))
505505
@test pointer(Transpose(C)) === pointer(C)
506506
D = rand(3,2) .+ rand(3,2).*im
507-
@test_throws MethodError pointer(Adjoint(D))
507+
@test_throws ErrorException pointer(Adjoint(D))
508508
@test pointer(Transpose(D)) === pointer(D)
509509
end
510510

0 commit comments

Comments
 (0)