# Convert failure in version 0.7

**URL:** <https://discourse.julialang.org/t/convert-failure-in-version-0-7/6513>\
**Category:** General Usage\
**Created:** [October 17, 2017, 9:38pm UTC](https://discourse.julialang.org/t/convert-failure-in-version-0-7/6513 "2017-10-17T21:38:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [October 17, 2017, 9:38pm UTC](https://discourse.julialang.org/t/convert-failure-in-version-0-7/6513/1 "2017-10-17T21:38:03Z")

</div>

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
julia> str="blabla";

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

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

```

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [October 17, 2017, 10:55pm UTC](https://discourse.julialang.org/t/convert-failure-in-version-0-7/6513/2 "2017-10-17T22:55:54Z")

</div>

What was the error?

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [October 17, 2017, 11:03pm UTC](https://discourse.julialang.org/t/convert-failure-in-version-0-7/6513/3 "2017-10-17T23:03:30Z")

</div>

Travis says

> **[Travis CI - Test and Deploy with Confidence](https://app.travis-ci.com/GenericMappingTools/GMT.jl/jobs/289125890)**
>
> Travis CI enables your team to test and ship your apps with confidence. Easily sync your projects with Travis CI and you'll be testing your code in minutes.

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

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [October 17, 2017, 11:30pm UTC](https://discourse.julialang.org/t/convert-failure-in-version-0-7/6513/4 "2017-10-17T23:30:14Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [October 18, 2017, 12:00am UTC](https://discourse.julialang.org/t/convert-failure-in-version-0-7/6513/5 "2017-10-18T00:00:29Z")

</div>

> 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.

> <https://github.com/GenericMappingTools/GMT.jl/blob/master/src/gmt_main.jl#L360>

> 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

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [October 18, 2017, 1:30am UTC](https://discourse.julialang.org/t/convert-failure-in-version-0-7/6513/6 "2017-10-18T01:30:36Z")

</div>

> [@joa-quim](#):
>
> master creates a Substring where 0.6 creates a string

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

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [October 18, 2017, 3:46pm UTC](https://discourse.julialang.org/t/convert-failure-in-version-0-7/6513/7 "2017-10-18T15:46:45Z")

</div>

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

```julia
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?

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [October 18, 2017, 4:02pm UTC](https://discourse.julialang.org/t/convert-failure-in-version-0-7/6513/8 "2017-10-18T16:02:53Z")

</div>

From the doc

```julia
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.
