Skip to content

Commit

Permalink
Fix mightalias ambiguities
Browse files Browse the repository at this point in the history
  • Loading branch information
oschulz committed Jul 24, 2024
1 parent 3fe2559 commit 2dd8dbc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/uview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,23 @@ 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
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))

Expand All @@ -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)

0 comments on commit 2dd8dbc

Please sign in to comment.