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

WARNING: convert(::Type{Ptr}, ::CUDArt.CudaPtr{Float32}) methods should be converted to be methods of unsafe_convert #10437

Closed
denizyuret opened this issue Mar 7, 2015 · 4 comments

Comments

@denizyuret
Copy link
Contributor

The latest snapshot of Julia makes CUDArt unusable because of nonstop warnings of the type given above. The warnings are generated by ccall instructions, and I suspect something needs to be fixed with ccall?

@denizyuret
Copy link
Contributor Author

Part of the issue seems to be that I can't seem to turn warnings off on worker processes. Even if I start julia with --depwarn=no, the workers do not inherit this. Maybe inheriting JLOptions() by children should be another issue?

@JeffBezanson
Copy link
Sponsor Member

This recent change deprecates conversion to Ptr since it's considered dangerous. The warning is telling all libraries that define conversions to Ptr to define unsafe_convert instead.

@vtjnash The following might be a problem, since it refers to a definition in Base:

julia> ccall(:jl_value_ptr, Ptr{Void}, (Ptr{Void},), 1)
WARNING: convert(::Type{Ptr}, ::Int64) methods should be converted to be methods of unsafe_convert
 in depwarn at ./deprecated.jl:40
 in anonymous at no file
Ptr{Void} @0x0000000000000001

@vtjnash
Copy link
Sponsor Member

vtjnash commented Mar 7, 2015

i might want to improve the text of that message, but that conversion is an error in C too.

we should probably add eval(Base, :(const unsafe_convert = cconvert)) to Compat.jl for v0.3

@JeffBezanson
Copy link
Sponsor Member

I think it might be more user-friendly for the fallbacks to be

cconvert(T::Type, x) = x
unsafe_convert(T::Type, x) = convert(T, x)

Those are easier to reason about. Then you have the option of just defining methods for convert, and they will be used, but if you want more safety you can choose to define Ptr conversions only for unsafe_convert.

(EDIT: This was Jameson's original approach in #9986, and he later changed it.)

@vtjnash vtjnash closed this as completed in 712f57f Mar 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants