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

Nothing field in immutable occupies nonzero space #8156

Closed
ivarne opened this issue Aug 27, 2014 · 3 comments
Closed

Nothing field in immutable occupies nonzero space #8156

ivarne opened this issue Aug 27, 2014 · 3 comments
Assignees

Comments

@ivarne
Copy link
Member

ivarne commented Aug 27, 2014

https://groups.google.com/forum/#!topic/julia-users/2uXsjXuXxn0

immutable MyType{A}
    a::A
end
sizeof(MyType(nothing))
8
sizeof(MyType(int8(1)))
1
sizeof(MyType(int16(1)))
2
sizeof(MyType(int32(1)))
4

sizeof(MyType(nothing)) should be 0, shouldn't it?

cc: @mlhetland

@pao pao changed the title Zero field immutable takes nonzero space in a type. Nothing field in immutable occupies nonzero space Aug 27, 2014
@pao
Copy link
Member

pao commented Aug 27, 2014

Renamed--the immutable type has a field, you've just given it a type that doesn't necessarily need space to represent.

@ivarne
Copy link
Member Author

ivarne commented Aug 28, 2014

immutable My{A, B}
    a::A
    b::B
end
My(nothing, 1)

Now causes segfault with the following backtrace:

signal (11): Segmentation fault: 11
pool_alloc at /Users/ivarne/dev/julia/src/gc.c:507
typeinf at ./inference.jl:1367
typeinf at /Users/ivarne/dev/julia/usr/lib/julia/sys.dylib (unknown line)
jl_apply at /Users/ivarne/dev/julia/src/./julia.h:987
typeinf_ext at ./inference.jl:1220
jl_apply at /Users/ivarne/dev/julia/src/./julia.h:987
jl_apply at /Users/ivarne/dev/julia/src/gf.c:393
jl_mt_assoc_by_type at /Users/ivarne/dev/julia/src/gf.c:980
jl_apply_generic at /Users/ivarne/dev/julia/src/gf.c:1581
eval_user_input at REPL.jl:55
jlcall_eval_user_input;138356 at  (unknown line)
jl_apply at /Users/ivarne/dev/julia/src/./julia.h:987
anonymous at task.jl:96
jl_apply at /Users/ivarne/dev/julia/src/task.c:427
julia_trampoline at /Users/ivarne/dev/julia/src/init.c:1011
Segmentation fault: 11

@ivarne ivarne reopened this Aug 28, 2014
@ivarne
Copy link
Member Author

ivarne commented Aug 28, 2014

Confirmed that it did not segfault on the parent commit of 6667e5d

kmsquire added a commit that referenced this issue Sep 3, 2014
This reverts commit 662cd0a.

Conflicts:
	test/core.jl
kmsquire added a commit that referenced this issue Sep 3, 2014
This reverts commit 6667e5d.

Conflicts:
	src/interpreter.c
	src/jltypes.c
kmsquire added a commit that referenced this issue Sep 3, 2014
Revert "allow more kinds of fields to take 0 space. fixes #8156"

This reverts commits 662cd0a,
                     6667e5d.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants