Convert failure in version 0.7


#1

I don’t have 0.7 installed yet but from the Travis nightly build failures this, that works fine on 0.6, fails with 0.7. Can someone please confirm?

julia> str="blabla";

julia> convert(Ptr{Void}, pointer(str))
Ptr{Void} @0x0000000020dcad58

julia> convert(Ptr{Void}, pointer(str[1:3]))
Ptr{Void} @0x0000000021179d98

#2

What was the error?


#3

Travis says

https://travis-ci.org/GenericMappingTools/GMT.jl/jobs/289125890#L2039

ERROR: LoadError: MethodError: no method matching unsafe_convert(::Type{Ptr{Void}}, ::SubString{String})


#4

According to the error/backtrace the code you post is not what’s causing the error. The GMT_Create_Options is passed a SubString and it is not supported on either 0.6 or master.

Note that the file libgmt.jl has a lot of issue about the ccall. Ref https://github.com/ihnorton/Clang.jl/issues/152 . The specific issue should be fixable if you replace the Ptr{Void} with Cstring though I’m not really sure if it’s compatible with other things.


#5

According to the error/backtrace the code you post is not what’s causing the error. The GMT_Create_Options is passed a SubString and it is not supported on either 0.6 or master.

I posted those examples because I suspected that master creates a Substring where 0.6 creates a string. The string argument to the function where the error occurs is obtained after a call to this strtok implementation.

The specific issue should be fixable if you replace the Ptr{Void} with Cstring …

Thanks, I’ll try to do it and see what breaks


#6

Yes, I traced it back to there too, though indexing is not how it’s generated, it’s lstrip.


#7

Right, and now I’m getting this failure (in 0.7)

isvalid(lstrip(" blabla"))
ERROR: MethodError: no method matching isvalid(::SubString{String})
Closest candidates are:
  isvalid(::SubString, ::Integer) at strings/types.jl:70
  isvalid(::AbstractString, ::Integer) at strings/basic.jl:228
  isvalid(::Char) at strings/utf8proc.jl:56

Is this on purpose?


#8

From the doc

help?> isvalid("aaa")
  isvalid(value) -> Bool

  Returns true if the given value is valid for its type, which currently can be either Char or
  String.

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  julia> isvalid(Char(0xd800))
  false

  julia> isvalid(Char(0xd799))
  true

This seems intentional though it should probably be fixed.