Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Aug 8, 2014
1 parent 9ee60bf commit 6bd8b56
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1520,8 +1520,14 @@ static Value *boxed(Value *v, jl_codectx_t *ctx, jl_value_t *jt)
if (jl_subtype(jt2, jt, 0))
jt = jt2;
}

if (jt == jl_bottom_type || v == NULL || dyn_cast<UndefValue>(v) != 0 || t == NoopType) {
UndefValue *uv = NULL;
if (jt == jl_bottom_type || v == NULL || (uv = dyn_cast<UndefValue>(v)) != 0 || t == NoopType) {
if (uv != NULL && jl_is_datatype(jt)) {
jl_datatype_t *jb = (jl_datatype_t*)jt;
// We have an undef value on a hopefully dead branch
if (jl_isbits(jb) && jb->size != 0)
return UndefValue::get(jl_pvalue_llvmt);
}
jl_value_t *s = static_void_instance(jt);
if (jl_is_tuple(jt) && jl_tuple_len(jt) > 0)
jl_add_linfo_root(ctx->linfo, s);
Expand Down
13 changes: 13 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1813,3 +1813,16 @@ type Foo7810{T<:AbstractVector}
end
bar7810() = [Foo7810([(a,b) for a in 1:2]) for b in 3:4]
@test Base.return_types(bar7810,())[1] == Array{Foo7810{Array{(Int,Int),1}},1}

# issue 7897
function issue7897!(data, arr)
data = reinterpret(Uint32, data)
a = arr[1]
end

a = ones(Uint8, 10)
sa = sub(a,4:6)
# This can throw an error, but shouldn't segfault
try
issue7897!(sa, zeros(10))
end

0 comments on commit 6bd8b56

Please sign in to comment.