Skip to content

Commit

Permalink
fix #2468, fix #2458 (add support for unsafe_ref(::Ptr{Any}))
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Mar 6, 2013
1 parent 2f46ffd commit b145dbe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,10 @@ static Value *emit_pointerref(jl_value_t *e, jl_value_t *i, jl_codectx_t *ctx)
Value *idx = emit_unbox(T_size, T_psize, emit_unboxed(i, ctx));
Value *im1 = builder.CreateSub(idx, ConstantInt::get(T_size, 1));
if (!jl_is_bitstype(ety)) {
if (ety == (jl_value_t*)jl_any_type)
return builder.CreateLoad(builder.CreateGEP(
builder.CreateBitCast(thePtr, jl_ppvalue_llvmt),
im1));
if (!jl_is_structtype(ety) || jl_is_array_type(ety) || !jl_is_leaf_type(ety))
jl_error("pointerref: invalid pointer type");
uint64_t size = ((jl_datatype_t*)ety)->size;
Expand Down
2 changes: 1 addition & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ begin
@test a == [11,99,13]
a2 = Any[101,102,103]
p2 = pointer(a2)
@test_fails unsafe_ref(p2) == 101
@test unsafe_ref(p2) == 101
@test_fails unsafe_assign(p2, 909, 3)
@test a2 == [101,102,103]
end
Expand Down

0 comments on commit b145dbe

Please sign in to comment.