Skip to content

Commit 7222d04

Browse files
gbaraldikpamnany
authored andcommitted
Fix layout flags for types that have oddly sized primitive type fields
1 parent 494de59 commit 7222d04

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/datatype.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,17 @@ void jl_compute_field_offsets(jl_datatype_t *st)
577577
// Should never happen
578578
throw_ovf(should_malloc, desc, st, fsz);
579579
desc[i].isptr = 0;
580+
580581
if (jl_is_uniontype(fld)) {
581582
haspadding = 1;
582583
fsz += 1; // selector byte
583584
zeroinit = 1;
584585
}
585586
else {
587+
if (fsz > jl_datatype_size(fld)) {
588+
// We have to pad the size to integer size class, but it means this has some padding
589+
haspadding = 1;
590+
}
586591
uint32_t fld_npointers = ((jl_datatype_t*)fld)->layout->npointers;
587592
if (((jl_datatype_t*)fld)->layout->haspadding)
588593
haspadding = 1;

test/core.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8085,3 +8085,9 @@ let widen_diagonal(x::UnionAll) = Base.rewrap_unionall(Base.widen_diagonal(Base.
80858085
@test Tuple === widen_diagonal(Union{Tuple{Vararg{S}}, Tuple{Vararg{T}}} where {S, T})
80868086
@test Tuple{Vararg{Val{<:Set}}} == widen_diagonal(Tuple{Vararg{T}} where T<:Val{<:Set})
80878087
end
8088+
8089+
#58434 bitsegal comparison of oddly sized fields
8090+
primitive type ByteString58434 (18 * 8) end
8091+
8092+
@test Base.datatype_isbitsegal(Tuple{ByteString58434}) == false
8093+
@test Base.datatype_haspadding(Tuple{ByteString58434}) == true

0 commit comments

Comments
 (0)