Skip to content

Commit 8652505

Browse files
committed
Add test for pointer.
1 parent 5b98e0e commit 8652505

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/OffsetArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ end
294294
A
295295
end
296296

297-
@inline Base.pointer(A::OffsetArray) = pointer(parent(A))
297+
@inline Base.unsafe_convert(::Type{Ptr{T}}, A::OffsetArray{T}) where {T} = pointer(parent(A))
298298

299299
# For fast broadcasting: ref https://discourse.julialang.org/t/why-is-there-a-performance-hit-on-broadcasting-with-offsetarrays/32194
300300
Base.dataids(A::OffsetArray) = Base.dataids(parent(A))

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,4 +1390,10 @@ end
13901390
@test arr == adapt(Array, s_arr)
13911391
end
13921392

1393+
@testset "Pointer" begin
1394+
A = rand(4, 5)
1395+
O = OffsetArray(@view(A[1:3,1:2:5]), -1:1, -1:1)
1396+
@test pointer(A) === pointer(O')
1397+
end
1398+
13931399
include("origin.jl")

0 commit comments

Comments
 (0)