Skip to content

Commit 2116922

Browse files
vtjnashKristofferC
authored andcommitted
fix missing layout allocation (#42035)
Fixes #41503 (cherry picked from commit 10755f7)
1 parent f14e50b commit 2116922

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/jltypes.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,9 +1547,8 @@ static jl_value_t *inst_datatype_inner(jl_datatype_t *dt, jl_svec_t *p, jl_value
15471547
// leading to incorrect layouts and data races (#40050: the A{T} should be
15481548
// an isbitstype singleton of size 0)
15491549
if (cacheable) {
1550-
if (dt->layout == NULL && !jl_is_primitivetype(dt) && ndt->types != NULL && ndt->isconcretetype) {
1550+
if (ndt->layout == NULL && ndt->types != NULL && ndt->isconcretetype)
15511551
jl_compute_field_offsets(ndt);
1552-
}
15531552
jl_cache_type_(ndt);
15541553
JL_UNLOCK(&typecache_lock); // Might GC
15551554
}

test/compiler/codegen.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,14 @@ f41438(y) = y[].x
594594
@test f41438(Ref{A41438}(A41438(C_NULL))) === C_NULL
595595
@test f41438(Ref{B41438}(B41438(C_NULL))) === C_NULL
596596

597+
const S41438 = Pair{Any, Ptr{T}} where T
598+
g41438() = Array{S41438,1}(undef,1)[1].first
599+
get_llvm(g41438, ()); # cause allocation of layout
600+
@test S41438.body.layout != C_NULL
601+
@test !Base.datatype_pointerfree(S41438.body)
602+
@test S41438{Int}.layout != C_NULL
603+
@test !Base.datatype_pointerfree(S41438{Int})
604+
597605
# issue #41157
598606
f41157(a, b) = a[1] = b[1]
599607
@test_throws BoundsError f41157(Tuple{Int}[], Tuple{Union{}}[])

0 commit comments

Comments
 (0)