Skip to content

Commit

Permalink
renames cconvert(cconvert_gcroot()) to unsafe_convert(cconvert())
Browse files Browse the repository at this point in the history
this also makes changes such that cconvert is mostly unchanged from its
functionality before this change. cconvert is expected to typically call
convert. in some cases (such as when intending to create a Ptr for
C-compatiblity), it should defer the actual unsafe step of making the
Ptr to unsafe_convert.

any code intending to allow conversion of an object to a Ptr should
define the operation as a method of unsafe_convert after this commit,
rather than the current behavior of making them a method of convert
  • Loading branch information
vtjnash committed Mar 7, 2015
1 parent 9edf5a4 commit 721f3e2
Show file tree
Hide file tree
Showing 23 changed files with 74 additions and 58 deletions.
2 changes: 1 addition & 1 deletion base/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ end

immutable LatexCompletions <: CompletionProvider; end

bytestring_beforecursor(buf::IOBuffer) = bytestring(pointer(buf.data), buf.ptr-1)
bytestring_beforecursor(buf::IOBuffer) = bytestring(buf.data[1:buf.ptr-1])

function complete_line(c::REPLCompletionProvider, s)
partial = bytestring_beforecursor(s.input_buffer)
Expand Down
8 changes: 4 additions & 4 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ function call{P<:Ptr,T}(::Type{Ref{P}}, a::Array{T}) # Ref{P<:Ptr}(a::Array)
ptrs = Array(P, length(a)+1)
roots = Array(Any, length(a))
for i = 1:length(a)
root = cconvert_gcroot(P, a[i])
ptrs[i] = cconvert(P, root)::P
root = cconvert(P, a[i])
ptrs[i] = unsafe_convert(P, root)::P
roots[i] = root
end
ptrs[length(a)+1] = C_NULL
return RefArray(ptrs,1,roots)
end
end
cconvert_gcroot{P<:Ptr,T<:Ptr}(::Union(Type{Ptr{P}},Type{Ref{P}}), a::Array{T}) = a
cconvert_gcroot{P<:Ptr}(::Union(Type{Ptr{P}},Type{Ref{P}}), a::Array) = Ref{P}(a)
cconvert{P<:Ptr,T<:Ptr}(::Union(Type{Ptr{P}},Type{Ref{P}}), a::Array{T}) = a
cconvert{P<:Ptr}(::Union(Type{Ptr{P}},Type{Ref{P}}), a::Array) = Ref{P}(a)

size(a::Array) = arraysize(a)
size(a::Array, d) = arraysize(a, d)
Expand Down
11 changes: 7 additions & 4 deletions base/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ cnvt_all(T) = ()
cnvt_all(T, x, rest...) = tuple(convert(T,x), cnvt_all(T, rest...)...)

# conversions used by ccall
ptr_arg_cconvert_gcroot{T}(::Type{Ptr{T}}, x) = cconvert_gcroot(T, x)
ptr_arg_cconvert{T}(::Type{Ptr{T}}, x) = cconvert(T, x)
ptr_arg_cconvert(::Type{Ptr{Void}}, x) = x
cconvert_gcroot(T, x) = x
cconvert(T, x) = convert(T,x)
ptr_arg_unsafe_convert{T}(::Type{Ptr{T}}, x) = unsafe_convert(T, x)
ptr_arg_unsafe_convert(::Type{Ptr{Void}}, x) = x

cconvert(T::Type, x) = convert(T, x) # do the conversion eagerly in most cases
cconvert{P<:Ptr}(::Type{P}, x) = x # but defer the conversion to Ptr to unsafe_convert
unsafe_convert{T}(::Type{T}, x::T) = x # unsafe_convert (like convert) defaults to assuming the convert occurred
unsafe_convert{P<:Ptr}(::Type{P}, x::Ptr) = convert(P, x)

reinterpret{T,S}(::Type{T}, x::S) = box(T,unbox(S,x))

Expand Down
15 changes: 15 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,21 @@ function subtypetree(x::DataType, level=-1)
(level == 0 ? (x, []) : (x, Any[subtypetree(y, level-1) for y in subtypes(x)]))
end

function unsafe_convert{P}(::Type{P}, x)
P<:Ptr || throw(MethodError(unsafe_convert, (Type{P}, x)))
depwarn("convert(::Type{Ptr}, ::$(typeof(x))) methods should be converted to be methods of unsafe_convert", :unsafe_convert)
return convert(P, x)
end

function convert{T}(::Type{Ptr{T}}, x::Integer)
depwarn("converting integers to pointers is discontinued", :convert)
box(Ptr{T},unbox(UInt,UInt(x)))
end
function convert{T}(::Type{Ptr{T}}, x::Signed)
depwarn("converting signed numbers to pointers is discontinued", :convert)
box(Ptr{T},unbox(Int,Int(x)))
end

# 8898
@deprecate precision(x::DateTime) eps(x)
@deprecate precision(x::Date) eps(x)
Expand Down
3 changes: 2 additions & 1 deletion base/fs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ end

isopen(f::Union(File,AsyncFile)) = f.open

# Not actually a pointer, but that's how we pass it through the C API so it's fine
uvhandle(file::File) = convert(Ptr{Void}, file.handle % UInt)
uvtype(::File) = Base.UV_RAW_FD
uvhandle(file::File) = file.handle

_uv_fs_result(req) = ccall(:jl_uv_fs_result,Int32,(Ptr{Void},),req)

Expand Down
2 changes: 1 addition & 1 deletion base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2376,7 +2376,7 @@ function inlineable(f::ANY, e::Expr, atypes::Tuple, sv::StaticVarInfo, enclosing
if incompletematch
cost *= 4
end
if is(f, next) || is(f, done) || is(f, cconvert) || is(f, cconvert_gcroot)
if is(f, next) || is(f, done) || is(f, unsafe_convert) || is(f, cconvert)
cost /= 4
end
if !inline_worthy(body, cost)
Expand Down
2 changes: 1 addition & 1 deletion base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function write(s::IO, p::Ptr, n::Integer)
end

function write(io::IO, s::Symbol)
pname = cconvert(Ptr{UInt8}, s)
pname = unsafe_convert(Ptr{UInt8}, s)
write(io, pname, int(ccall(:strlen, Csize_t, (Ptr{UInt8},), pname)))
end

Expand Down
2 changes: 1 addition & 1 deletion base/iostream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function IOStream(name::AbstractString, finalize::Bool)
end
IOStream(name::AbstractString) = IOStream(name, true)

convert(T::Type{Ptr{Void}}, s::IOStream) = convert(T, pointer(s.ios))
unsafe_convert(T::Type{Ptr{Void}}, s::IOStream) = convert(T, pointer(s.ios))
show(io::IO, s::IOStream) = print(io, "IOStream(", s.name, ")")
fd(s::IOStream) = int(ccall(:jl_ios_fd, Clong, (Ptr{Void},), s.ios))
stat(s::IOStream) = stat(fd(s))
Expand Down
20 changes: 10 additions & 10 deletions base/pointer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ convert{T<:Union(Int,UInt)}(::Type{T}, x::Ptr) = box(T, unbox(Ptr,x))
convert{T<:Integer}(::Type{T}, x::Ptr) = convert(T,unsigned(x))

# integer to pointer
convert{T}(::Type{Ptr{T}}, x::Integer) = box(Ptr{T},unbox(UInt,UInt(x)))
convert{T}(::Type{Ptr{T}}, x::Signed) = box(Ptr{T},unbox(Int,Int(x)))
convert{T}(::Type{Ptr{T}}, x::UInt) = box(Ptr{T},unbox(UInt,UInt(x)))
convert{T}(::Type{Ptr{T}}, x::Int) = box(Ptr{T},unbox(Int,Int(x)))

# pointer to pointer
convert{T}(::Type{Ptr{T}}, p::Ptr{T}) = p
convert{T}(::Type{Ptr{T}}, p::Ptr) = box(Ptr{T}, unbox(Ptr,p))

# object to pointer (when used with ccall)
cconvert(::Type{Ptr{UInt8}}, x::Symbol) = ccall(:jl_symbol_name, Ptr{UInt8}, (Any,), x)
cconvert(::Type{Ptr{Int8}}, x::Symbol) = ccall(:jl_symbol_name, Ptr{Int8}, (Any,), x)
cconvert(::Type{Ptr{UInt8}}, s::ByteString) = cconvert(Ptr{UInt8}, s.data)
cconvert(::Type{Ptr{Int8}}, s::ByteString) = cconvert(Ptr{Int8}, s.data)
unsafe_convert(::Type{Ptr{UInt8}}, x::Symbol) = ccall(:jl_symbol_name, Ptr{UInt8}, (Any,), x)
unsafe_convert(::Type{Ptr{Int8}}, x::Symbol) = ccall(:jl_symbol_name, Ptr{Int8}, (Any,), x)
unsafe_convert(::Type{Ptr{UInt8}}, s::ByteString) = unsafe_convert(Ptr{UInt8}, s.data)
unsafe_convert(::Type{Ptr{Int8}}, s::ByteString) = unsafe_convert(Ptr{Int8}, s.data)
# convert strings to ByteString to pass as pointers
cconvert_gcroot(::Type{Ptr{UInt8}}, s::AbstractString) = bytestring(s)
cconvert_gcroot(::Type{Ptr{Int8}}, s::AbstractString) = bytestring(s)
cconvert(::Type{Ptr{UInt8}}, s::AbstractString) = bytestring(s)
cconvert(::Type{Ptr{Int8}}, s::AbstractString) = bytestring(s)

cconvert{T}(::Type{Ptr{T}}, a::Array{T}) = ccall(:jl_array_ptr, Ptr{T}, (Any,), a)
cconvert(::Type{Ptr{Void}}, a::Array) = ccall(:jl_array_ptr, Ptr{Void}, (Any,), a)
unsafe_convert{T}(::Type{Ptr{T}}, a::Array{T}) = ccall(:jl_array_ptr, Ptr{T}, (Any,), a)
unsafe_convert(::Type{Ptr{Void}}, a::Array) = ccall(:jl_array_ptr, Ptr{Void}, (Any,), a)

# unsafe pointer to array conversions
pointer_to_array(p, d::Integer, own=false) = pointer_to_array(p, (d,), own)
Expand Down
9 changes: 4 additions & 5 deletions base/process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ uvhandle(x::Ptr) = x
uvtype(::Ptr) = UV_STREAM
uvtype(::DevNullStream) = UV_STREAM

# Not actually a pointer, but that's how we pass it through the C API
# so it's fine
uvhandle(x::RawFD) = convert(Ptr{Void}, x.fd)
# Not actually a pointer, but that's how we pass it through the C API so it's fine
uvhandle(x::RawFD) = convert(Ptr{Void}, x.fd % UInt)
uvtype(x::RawFD) = UV_RAW_FD

typealias Redirectable Union(UVStream, FS.File, FileRedirect, DevNullStream, IOStream, RawFD)
Expand Down Expand Up @@ -220,7 +219,7 @@ end
function uvfinalize(proc::Process)
proc.handle != C_NULL && ccall(:jl_close_uv, Void, (Ptr{Void},), proc.handle)
disassociate_julia_struct(proc)
proc.handle = 0
proc.handle = C_NULL
end

function _uv_hook_return_spawn(proc::Process, exit_status::Int64, termsignal::Int32)
Expand All @@ -232,7 +231,7 @@ function _uv_hook_return_spawn(proc::Process, exit_status::Int64, termsignal::In
end

function _uv_hook_close(proc::Process)
proc.handle = 0
proc.handle = C_NULL
if isa(proc.closecb, Function) proc.closecb(proc) end
notify(proc.closenotify)
end
Expand Down
8 changes: 4 additions & 4 deletions base/profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ immutable LineInfo
file::ByteString
line::Int
fromC::Bool
ip::Int
ip::Int64 # large enough that this struct can be losslessly read on any machine (32 or 64 bit)
end

const UNKNOWN = LineInfo("?", "?", -1, true, 0)
Expand Down Expand Up @@ -130,15 +130,15 @@ len_data() = convert(Int, ccall(:jl_profile_len_data, Csize_t, ()))

maxlen_data() = convert(Int, ccall(:jl_profile_maxlen_data, Csize_t, ()))

function lookup(ip::UInt)
function lookup(ip::Ptr{Void})
info = ccall(:jl_lookup_code_address, Any, (Ptr{Void},Cint), ip, false)
if length(info) == 5
return LineInfo(string(info[1]), string(info[2]), int(info[3]), info[4], int(info[5]))
return LineInfo(string(info[1]), string(info[2]), int(info[3]), info[4], int64(info[5]))
else
return UNKNOWN
end
end
lookup(ip::Ptr{Void}) = lookup(UInt(ip))
lookup(ip::UInt) = lookup(convert(Ptr{Void},ip))

error_codes = Dict{Int,ASCIIString}(
-1=>"cannot specify signal action for profiling",
Expand Down
19 changes: 9 additions & 10 deletions base/refpointer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Base.eltype{T}(x::Type{Ref{T}}) = T
Base.convert{T}(::Type{Ref{T}}, x::Ref{T}) = x

# create Ref objects for general object conversion
Base.cconvert_gcroot{T}(::Type{Ref{T}}, x) = convert(Ref{T}, x)
Base.cconvert{T}(::Type{Ref{T}}, x) = cconvert(Ptr{T}, x)
Base.unsafe_convert{T}(::Type{Ref{T}}, x) = unsafe_convert(Ptr{T}, x)

### Methods for a Ref object that can store a single value of any type

Expand All @@ -24,25 +23,25 @@ Base.call{T}(::Type{Ref{T}}) = RefValue{T}() # Ref{T}()
Base.call{T}(::Type{Ref{T}}, x) = RefValue{T}(x) # Ref{T}(x)
Base.convert{T}(::Type{Ref{T}}, x) = RefValue{T}(x)

function Base.cconvert{T}(P::Type{Ptr{T}}, b::RefValue{T})
function Base.unsafe_convert{T}(P::Type{Ptr{T}}, b::RefValue{T})
if isbits(T)
return convert(P, data_pointer_from_objref(b))
else
return convert(P, data_pointer_from_objref(b.x))
end
end
function Base.cconvert(P::Type{Ptr{Any}}, b::RefValue{Any})
function Base.unsafe_convert(P::Type{Ptr{Any}}, b::RefValue{Any})
return convert(P, data_pointer_from_objref(b))
end
Base.cconvert{T}(::Type{Ptr{Void}}, b::RefValue{T}) = Base.convert(Ptr{Void}, Base.cconvert(Ptr{T}, b))
Base.unsafe_convert{T}(::Type{Ptr{Void}}, b::RefValue{T}) = Base.convert(Ptr{Void}, Base.unsafe_convert(Ptr{T}, b))

### Methods for a Ref object that is backed by an array at index i

# note: the following type definitions don't mean any AbstractArray is convertible to
# a data Ref. they just map the array element type to the pointer type for
# convenience in cases that work.
pointer{T}(x::AbstractArray{T}) = cconvert(Ptr{T}, x)
pointer{T}(x::AbstractArray{T}, i::Integer) = cconvert(Ptr{T},x) + (i-1)*elsize(x)
pointer{T}(x::AbstractArray{T}) = unsafe_convert(Ptr{T}, x)
pointer{T}(x::AbstractArray{T}, i::Integer) = unsafe_convert(Ptr{T},x) + (i-1)*elsize(x)

immutable RefArray{T, A<:AbstractArray, R} <: Ref{T}
x::A
Expand All @@ -55,17 +54,17 @@ RefArray{T}(x::AbstractArray{T},i::Int=1,roots::Void=nothing) = RefArray{T,typeo
Base.convert{T}(::Type{Ref{T}}, x::AbstractArray{T}) = RefArray(x, 1)
Ref(x::AbstractArray, i::Integer=1) = RefArray(x, i)

function Base.cconvert{T}(P::Type{Ptr{T}}, b::RefArray{T})
function Base.unsafe_convert{T}(P::Type{Ptr{T}}, b::RefArray{T})
if isbits(T)
convert(P, pointer(b.x, b.i))
else
convert(P, data_pointer_from_objref(b.x[b.i]))
end
end
function Base.cconvert(P::Type{Ptr{Any}}, b::RefArray{Any})
function Base.unsafe_convert(P::Type{Ptr{Any}}, b::RefArray{Any})
return convert(P, pointer(b.x, b.i))
end
Base.cconvert{T}(::Type{Ptr{Void}}, b::RefArray{T}) = Base.convert(Ptr{Void}, Base.cconvert(Ptr{T}, b))
Base.unsafe_convert{T}(::Type{Ptr{Void}}, b::RefArray{T}) = Base.convert(Ptr{Void}, Base.unsafe_convert(Ptr{T}, b))

###

Expand Down
2 changes: 1 addition & 1 deletion base/serialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function serialize(s, x::Symbol)
if haskey(ser_tag, x)
return write_as_tag(s, x)
end
pname = cconvert(Ptr{UInt8}, x)
pname = unsafe_convert(Ptr{UInt8}, x)
ln = int(ccall(:strlen, Csize_t, (Ptr{UInt8},), pname))
if ln <= 255
writetag(s, Symbol)
Expand Down
2 changes: 1 addition & 1 deletion base/sharedarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ sdata(A::AbstractArray) = A

localindexes(S::SharedArray) = S.pidx > 0 ? range_1dim(S, S.pidx) : 1:0

cconvert{T}(::Type{Ptr{T}}, S::SharedArray) = cconvert(Ptr{T}, sdata(S))
unsafe_convert{T}(::Type{Ptr{T}}, S::SharedArray) = unsafe_convert(Ptr{T}, sdata(S))

convert(::Type{SharedArray}, A::Array) = (S = SharedArray(eltype(A), size(A)); copy!(S, A))
convert{T}(::Type{SharedArray{T}}, A::Array) = (S = SharedArray(T, size(A)); copy!(S, A))
Expand Down
6 changes: 3 additions & 3 deletions base/socket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ end
function uvfinalize(uv)
close(uv)
disassociate_julia_struct(uv)
uv.handle = 0
uv.handle = C_NULL
end

isreadable(io::TCPSocket) = true
Expand Down Expand Up @@ -395,11 +395,11 @@ function uvfinalize(uv::Union(TTY,Pipe,PipeServer,TCPServer,TCPSocket,UDPSocket)
close(uv)
end
disassociate_julia_struct(uv)
uv.handle = 0
uv.handle = C_NULL
end

function _uv_hook_close(sock::UDPSocket)
sock.handle = 0
sock.handle = C_NULL
sock.status = StatusClosed
notify(sock.closenotify)
notify(sock.sendnotify)
Expand Down
2 changes: 1 addition & 1 deletion base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ end
close(t::Timer) = ccall(:jl_close_uv,Void,(Ptr{Void},),t.handle)

function _uv_hook_close(uv::Union(AsyncStream,UVServer))
uv.handle = 0
uv.handle = C_NULL
uv.status = StatusClosed
if isa(uv.closecb, Function)
uv.closecb(uv)
Expand Down
2 changes: 1 addition & 1 deletion base/string.jl
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ function getindex(s::AbstractString, r::UnitRange{Int})
SubString(s, first(r), last(r))
end

function cconvert{P<:Union(Int8,UInt8),T<:ByteString}(::Type{Ptr{P}}, s::SubString{T})
function unsafe_convert{P<:Union(Int8,UInt8),T<:ByteString}(::Type{Ptr{P}}, s::SubString{T})
if s.offset+s.endof < endof(s.string)
throw(ArgumentError("a SubString must coincide with the end of the original string to be convertible to pointer"))
end
Expand Down
6 changes: 3 additions & 3 deletions base/subarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,11 @@ function subarray_linearindexing_dim{A<:AbstractArray}(::Type{A}, It::Tuple)
LD
end

cconvert{T,N,P<:Array,I<:(RangeIndex...)}(::Type{Ptr{T}}, V::SubArray{T,N,P,I}) =
unsafe_convert{T,N,P<:Array,I<:(RangeIndex...)}(::Type{Ptr{T}}, V::SubArray{T,N,P,I}) =
pointer(V.parent) + (V.first_index-1)*sizeof(T)

cconvert{T,N,P<:Array,I<:(RangeIndex...)}(::Type{Ptr{Void}}, V::SubArray{T,N,P,I}) =
convert(Ptr{Void}, cconvert(Ptr{T}, V))
unsafe_convert{T,N,P<:Array,I<:(RangeIndex...)}(::Type{Ptr{Void}}, V::SubArray{T,N,P,I}) =
convert(Ptr{Void}, unsafe_convert(Ptr{T}, V))

pointer(V::SubArray, i::Int) = pointer(V, ind2sub(size(V), i))

Expand Down
2 changes: 1 addition & 1 deletion base/utf16.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ convert(::Type{UTF8String}, s::UTF16String) =
sprint(length(s.data)-1, io->for c in s; write(io,c::Char); end)

sizeof(s::UTF16String) = sizeof(s.data) - sizeof(UInt16)
cconvert{T<:Union(Int16,UInt16)}(::Type{Ptr{T}}, s::UTF16String) =
unsafe_convert{T<:Union(Int16,UInt16)}(::Type{Ptr{T}}, s::UTF16String) =
convert(Ptr{T}, pointer(s))

function is_valid_utf16(data::AbstractArray{UInt16})
Expand Down
2 changes: 1 addition & 1 deletion base/utf32.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ convert(::Type{Array{Char}}, s::UTF32String) = s.data
reverse(s::UTF32String) = UTF32String(reverse!(copy(s.data), 1, length(s)))

sizeof(s::UTF32String) = sizeof(s.data) - sizeof(Char)
cconvert{T<:Union(Int32,UInt32,Char)}(::Type{Ptr{T}}, s::UTF32String) =
unsafe_convert{T<:Union(Int32,UInt32,Char)}(::Type{Ptr{T}}, s::UTF32String) =
convert(Ptr{T}, pointer(s))

function convert(T::Type{UTF32String}, bytes::AbstractArray{UInt8})
Expand Down
4 changes: 2 additions & 2 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1011,8 +1011,8 @@
(let* ((g (make-jlgensym))
(isamp (and (pair? a) (eq? (car a) '&)))
(a (if isamp (cadr a) a))
(stmts (cons `(= ,g (call (top ,(if isamp 'ptr_arg_cconvert_gcroot 'cconvert_gcroot)) ,ty ,a)) stmts))
(ca `(call (top ,(if isamp 'ptr_arg_cconvert 'cconvert)) ,ty ,g)))
(stmts (cons `(= ,g (call (top ,(if isamp 'ptr_arg_cconvert 'cconvert)) ,ty ,a)) stmts))
(ca `(call (top ,(if isamp 'ptr_arg_unsafe_convert 'unsafe_convert)) ,ty ,g)))
(loop (if isseq F (cdr F)) (cdr A) stmts
(list* g (if isamp `(& ,ca) ca) C))))))))

Expand Down
2 changes: 1 addition & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ type Z4681
x::Ptr{Void}
Z4681() = new(C_NULL)
end
Base.convert(::Type{Ptr{Z4681}},b::Z4681) = b.x
Base.unsafe_convert(::Type{Ptr{Z4681}},b::Z4681) = b.x
@test_throws TypeError ccall(:printf,Int,(Ptr{UInt8},Ptr{Z4681}),"",Z4681())

# issue #4479
Expand Down
1 change: 0 additions & 1 deletion test/intfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,4 @@ let ptr = Ptr{Void}(typemax(UInt))
@test ptr == Ptr{Void}(T(ptr))
@test typeof(Ptr{Float64}(T(ptr))) == Ptr{Float64}
end
@test ptr == Ptr{Void}(Int8(-1)) # signed values are sign-extended to Int
end

0 comments on commit 721f3e2

Please sign in to comment.