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

Doc for ccall with Union{} return type #14685

Closed
ihnorton opened this issue Jan 15, 2016 · 3 comments
Closed

Doc for ccall with Union{} return type #14685

ihnorton opened this issue Jan 15, 2016 · 3 comments
Labels
docs This change adds or pertains to documentation

Comments

@ihnorton
Copy link
Member

While trying to repro the LibExpat failure from this PkgEval run, I ran in to the following, with both LLVM 3.3 and 3.7.1:

Version 0.5.0-dev+2137 (2016-01-14 22:40 UTC)
Commit b2b60c4* (0 days old master)
x86_64-apple-darwin15.2.0
julia> xph = ccall((:XML_ParserCreate, :libexpat), Ptr{Void}, (Ptr{Void},), C_NULL)
Ptr{Void} @0x00007fbc2c26edb0

julia> ccall((:XML_ParserFree, :libexpat), Union{}, (Ptr{Void},), xph)

signal (11): Segmentation fault: 11
while loading no file, in expression starting on line 0
[inline] at /Users/inorton/git/julia/src/jltypes.c:69
jl_is_type at /Users/inorton/git/julia/src/jltypes.c:2064
jl_inst_concrete_tupletype_v at /Users/inorton/git/julia/src/jltypes.c:2206
jl_f_tuple at /Users/inorton/git/julia/src/builtins.c:666
eval_user_input at REPL.jl:65
jlcall_eval_user_input_23657 at  (unknown line)
[inline] at REPL.jl:92
anonymous at task.jl:63
[inline] at /Users/inorton/git/julia/src/./julia.h:1391
jl_apply at /Users/inorton/git/julia/src/task.c:246
Segmentation fault: 11
@vtjnash
Copy link
Member

vtjnash commented Jan 15, 2016

that's supposed to segfault. the Union{} return type means "I don't return" (e.g. jl_error or longjmp), not "I return nothing"

@ihnorton ihnorton added the docs This change adds or pertains to documentation label Jan 15, 2016
@ihnorton ihnorton changed the title Segfault with ccall Union{} return type Doc for ccall with Union{} return type Jan 15, 2016
@ihnorton
Copy link
Member Author

That's kind of surprising, and it doesn't seem to be documented. Can we do something like ccall( ..., :noreturn, ...), and make the Union{} construct an error?

Changing to a doc issue for now.

@TotalVerb
Copy link
Contributor

I don't think it is so surprising.

julia> isa(nothing, Union{})
false

julia> isa(nothing, Void)
true

Seems consistent to me.

yuyichao added a commit to yuyichao/LibExpat.jl that referenced this issue Jan 23, 2016
yuyichao added a commit to yuyichao/LibExpat.jl that referenced this issue Jan 23, 2016
yuyichao added a commit that referenced this issue Apr 7, 2016
yuyichao added a commit that referenced this issue Apr 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

No branches or pull requests

3 participants