From 2dd8dbc6c1eae89a983ed7484fd3c9f5be8711c6 Mon Sep 17 00:00:00 2001 From: Oliver Schulz Date: Wed, 24 Jul 2024 12:20:25 +0200 Subject: [PATCH] Fix mightalias ambiguities --- src/uview.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/uview.jl b/src/uview.jl index 0d63e8a..5f58445 100644 --- a/src/uview.jl +++ b/src/uview.jl @@ -154,6 +154,7 @@ function Base.mightalias(A::UnsafeArray, B::AbstractArray) if typeof(B) <: UnsafeArray Base.mightalias(A, B) else + # Don't know if A and B might alias: false end end @@ -161,9 +162,15 @@ end Base.mightalias(A::AbstractArray, B::UnsafeArray) = Base.mightalias(B, A) +# Need to specialize mightalias SubArrays of UnsafeArrays since the +# default mightalias implementation returns false for all isbits types: + Base.mightalias(A::SubArray{T,N,<:UnsafeArray}, B::AbstractArray) where {T,N} = Base.mightalias(parent(A), B) +Base.mightalias(A::SubArray{T,N,<:UnsafeArray}, B::SubArray) where {T,N} = + Base.mightalias(parent(A), B) + Base.mightalias(A::SubArray{T1,N1,<:UnsafeArray}, B::SubArray{T2,N2,<:UnsafeArray}) where {T1,N1,T2,N2} = Base.mightalias(parent(A), parent(B)) @@ -173,5 +180,8 @@ Base.mightalias(A::SubArray{T,N,<:UnsafeArray}, B::UnsafeArray) where {T,N} = Base.mightalias(A::AbstractArray, B::SubArray{T,N,<:UnsafeArray}) where {T,N} = Base.mightalias(B, A) +Base.mightalias(A::SubArray, B::SubArray{T,N,<:UnsafeArray}) where {T,N} = + Base.mightalias(B, A) + Base.mightalias(A::UnsafeArray, B::SubArray{T,N,<:UnsafeArray}) where {T,N} = Base.mightalias(B, A)