Skip to content

Commit 14ff357

Browse files
committed
Fix layout flags for types that have oddly sized primitive type fields
1 parent eebda6c commit 14ff357

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
@@ -702,6 +702,11 @@ void jl_compute_field_offsets(jl_datatype_t *st)
702702
// Should never happen
703703
throw_ovf(should_malloc, desc, st, fsz);
704704
desc[i].isptr = 0;
705+
if (fsz > jl_datatype_size(fld)) {
706+
// We have to pad the size to integer size class, but it means this has some padding
707+
isbitsegal = 0;
708+
haspadding = 1;
709+
}
705710
if (jl_is_uniontype(fld)) {
706711
fsz += 1; // selector byte
707712
zeroinit = 1;

test/core.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8534,3 +8534,9 @@ module GlobalBindingMulti
85348534
using .M.C
85358535
end
85368536
@test GlobalBindingMulti.S === GlobalBindingMulti.M.C.S
8537+
8538+
#58434 bitsegal comparison of oddly sized fields
8539+
primitive type ByteString58434 (18 * 8) end
8540+
8541+
@test Base.datatype_isbitsegal(Tuple{ByteString58434}) == false
8542+
@test Base.datatype_haspadding(Tuple{ByteString58434}) == true

0 commit comments

Comments
 (0)