-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
ccall: WARNING: convert{T}(p::Type{Ptr{T}},a::Array) is deprecated, use convert(p,pointer(a)) instead. #7694
Comments
I don't think we should allow silently converting to a mismatched pointer type. Yes, this warning is not perfect, but I'm ok with it --- |
I think we badly need a system for pattern matching on warnings and showing more helpful errors and warnings. This was suggested by someone (@ivarne maybe) regarding certain method missing errors but could be very useful more generally. It should be done upon displaying the error, not generating it, since it's effectively a presentation-level concern. |
My main issue with it is that, while I suspected something like this issue, it took me a bit of hunting and poking at generated code to find. I'm not sure pattern matching would help here. |
Ref: #7512 Pattern matching on method errors can anyway only help after the depreciation is removed. Now we will just need to improve the warning message so that people understand what and why. |
The unit tests were causing the following warning to be printed: WARNING: convert{T}(p::Type{Ptr{T}},a::Array) is deprecated, use convert(p,pointer(a)) instead. in convert at deprecated.jl:26 in PQexecPrepared at /home/srp/.julia/PostgreSQL/src/libpq_common.jl:4 in executemany at /home/srp/.julia/PostgreSQL/src/dbi.jl:211 in test_dbi at /home/srp/.julia/PostgreSQL/test/dbi.jl:91 in include at ./boot.jl:245 in include_from_node1 at ./loading.jl:128 in include at ./boot.jl:245 in include_from_node1 at loading.jl:128 in process_options at ./client.jl:285 in _start at ./client.jl:354 This fixes that. See JuliaLang/julia#7694 for more info
I'm getting this when I call
ccall
with anArray
is passed in where a pointer is expected, specifically when theArray
type does not match the pointer type. When the types match, no warning is given.This is behavior is probably partially correct, but
ccall
with an array of a different type than the pointer is valid.For 2, specifically, I'm calling a function in
libavutil
which expects aPtr{Picture}
, but you can (and often do) pass aPtr{AVFrame}
because the initial layout is identical.Converting the array to a
pointer
first fixes this, and is an easy solution, except that it goes against the recommendation that one not make ccalls with pointers.The only question here I think is how to fix this:
convert(::Ptr{T}, ::Array{S})
whenS!=T
Thoughts?
The text was updated successfully, but these errors were encountered: