Skip to content

Type piracy in unsafe_convert #205

Closed
@KristofferC

Description

@KristofferC
julia> @which Base.unsafe_convert(Ptr{ComplexF64}, [1.0+im]')
unsafe_convert(::Type{Ptr{T}}, a::AbstractArray{T}) where T
     @ Base pointer.jl:67

julia> using ArrayLayouts

julia> @which Base.unsafe_convert(Ptr{ComplexF64}, [1.0+im]')
unsafe_convert(::Type{Ptr{T}}, Ac::LinearAlgebra.Adjoint{<:Complex}) where T<:Complex
     @ ArrayLayouts ~/PkgEvalAnalysis/dev/ArrayLayouts.jl/src/ArrayLayouts.jl:100

Also, this package errors on 1.11 due to:

LayoutMatrix: Error During Test at /home/pkgeval/.julia/packages/ArrayLayouts/i2w0I/test/test_layoutarray.jl:72
  Test threw exception
  Expression: ldiv!(Tri(A), copy(b))  ldiv!(Tri(A.A), copy(b))  Tri(A.A) \ MyVector(b)
  conversion to pointer not defined for Matrix{Float64}
  Stacktrace:
    [1] error(s::String)
      @ Base ./error.jl:35
    [2] unsafe_convert(::Type{Ptr{Float64}}, a::Matrix{Float64})
      @ Base ./pointer.jl:67
    [3] unsafe_convert(::Type{Ptr{Float64}}, A::Main.ArrayLayoutsTests.TestLayoutArray.MyMatrix)
      @ Main.ArrayLayoutsTests.TestLayoutArray ~/.julia/packages/ArrayLayouts/i2w0I/test/test_layoutarray.jl:16
    [4] trsv!(uplo::Char, trans::Char, diag::Char, A::Main.ArrayLayoutsTests.TestLayoutArray.MyMatrix, x::Vector{Float64})
      @ LinearAlgebra.BLAS /opt/julia/share/julia/stdlib/v1.11/LinearAlgebra/src/blas.jl:1375
    [5] materialize!
      @ ~/.julia/packages/ArrayLayouts/i2w0I/src/triangular.jl:215 [inlined]
    [6] ldiv!
      @ ~/.julia/packages/ArrayLayouts/i2w0I/src/ldiv.jl:101 [inlined]
    [7] ldiv!(A::LinearAlgebra.UpperTriangular{Float6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions