diff --git a/src/cgutils.cpp b/src/cgutils.cpp index 95cb22b4c85ff..26ec40d9be9e1 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -1033,7 +1033,7 @@ static bool emit_getfield_unknownidx(jl_cgval_t *ret, const jl_cgval_t &strct, V builder.CreateGEP(data_pointer(strct, ctx), idx))); if ((unsigned)stt->ninitialized != nfields) null_pointer_check(fld, ctx); - *ret = mark_julia_type(fld, true, jl_any_type, ctx, true); + *ret = mark_julia_type(fld, true, jl_any_type, ctx, strct.gcroot || !strct.isimmutable); return true; } else if (is_tupletype_homogeneous(stt->types)) { @@ -1110,7 +1110,7 @@ static jl_cgval_t emit_getfield_knownidx(const jl_cgval_t &strct, unsigned idx, Value *fldv = tbaa_decorate(tbaa, builder.CreateLoad(emit_bitcast(addr, T_ppjlvalue))); if (idx >= (unsigned)jt->ninitialized) null_pointer_check(fldv, ctx); - jl_cgval_t ret = mark_julia_type(fldv, true, jfty, ctx, true); + jl_cgval_t ret = mark_julia_type(fldv, true, jfty, ctx, strct.gcroot || !strct.isimmutable); return ret; } else {