From 0f790da847daddd76e0113703b02a3a1ae631304 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Fri, 5 Jul 2024 13:23:19 +0200 Subject: [PATCH] JLArrays: Disallow conversions to CPU pointers. --- lib/JLArrays/src/JLArrays.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/JLArrays/src/JLArrays.jl b/lib/JLArrays/src/JLArrays.jl index 10d53daa..318d4411 100644 --- a/lib/JLArrays/src/JLArrays.jl +++ b/lib/JLArrays/src/JLArrays.jl @@ -270,8 +270,10 @@ Base.elsize(::Type{<:JLArray{T}}) where {T} = sizeof(T) Base.size(x::JLArray) = x.dims Base.sizeof(x::JLArray) = Base.elsize(x) * length(x) -Base.unsafe_convert(::Type{Ptr{T}}, x::JLArray{T}) where {T} = - convert(Ptr{T}, pointer(x.data[])) + x.offset*Base.elsize(x) +function Base.unsafe_convert(::Type{Ptr{T}}, x::JLArray{T}) where {T} + error("Illegal conversion of a JLArray to a Ptr") + #convert(Ptr{T}, pointer(x.data[])) + x.offset*Base.elsize(x) +end ## interop with Julia arrays