Skip to content

Commit

Permalink
fix #40050, handling fields that are pointers due to subtype circular…
Browse files Browse the repository at this point in the history
…ity (#40095)

(cherry picked from commit e3dffb9)
  • Loading branch information
JeffBezanson authored and KristofferC committed Mar 26, 2021
1 parent ca12dcc commit 9d30535
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,10 @@ static Type *_julia_struct_to_llvm(jl_codegen_params_t *ctx, jl_value_t *jt, jl_
size_t fsz = 0, al = 0;
bool isptr = !jl_islayout_inline(ty, &fsz, &al);
if (jst->layout) {
assert(isptr == jl_field_isptr(jst, i));
// NOTE: jl_field_isptr can disagree with jl_islayout_inline here if the
// struct decided this field must be a pointer due to a type circularity.
// Example from issue #40050: `struct B <: Ref{Tuple{B}}; end`
isptr = jl_field_isptr(jst, i);
assert((isptr ? sizeof(void*) : fsz + jl_is_uniontype(ty)) == jl_field_size(jst, i));
}
Type *lty;
Expand Down
5 changes: 5 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7224,6 +7224,11 @@ end
@test_broken isbitstype(Tuple{B33954})
@test_broken isbitstype(B33954)

struct B40050 <: Ref{Tuple{B40050}}
end
@test string((B40050(),)) == "($B40050(),)"
@test_broken isbitstype(Tuple{B40050})

# Issue #34206/34207
function mre34206(a, n)
va = view(a, :)
Expand Down

0 comments on commit 9d30535

Please sign in to comment.