Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsafe_convert fails for array views with non-Int indices #42120

Open
nalimilan opened this issue Sep 4, 2021 · 1 comment
Open

unsafe_convert fails for array views with non-Int indices #42120

nalimilan opened this issue Sep 4, 2021 · 1 comment
Labels
arrays [a, r, r, a, y, s]

Comments

@nalimilan
Copy link
Member

This was reported at JuliaStats/Distances.jl#227. unsafe_convert appears to require SubArray inputs to have Int indices. This is due to the use of RangeIndex in the signature. Is there any reason not to support other integer types?

julia> data = rand(100);

julia> my_view = @view data[1:UInt64(50)];

julia> Base.unsafe_convert(Ptr{Float64}, my_view)
ERROR: conversion to pointer not defined for SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{UInt64}}, true}
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] unsafe_convert(#unused#::Type{Ptr{Float64}}, a::SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{UInt64}}, true})
   @ Base ./pointer.jl:67
 [3] top-level scope
   @ REPL[20]:1

(FWIW RangeIndex is a very old alias, it was even was originally written Union(Int, Range{Int}, UnitRange{Int}, Colon).)

@mkitti
Copy link
Contributor

mkitti commented Sep 28, 2022

I think the solution to this is #43262

manuelbb-upb added a commit to manuelbb-upb/Compromise.jl that referenced this issue Apr 23, 2024
due to JuliaLang/julia#42120 the prior
solution using views did not work with fortran evaluators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s]
Projects
None yet
Development

No branches or pull requests

2 participants