summaryrefslogtreecommitdiffstats
path: root/struct.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-05-18 08:10:50 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-05-18 08:10:50 -0700
commitce3623c412b23252b7720e4fb8cc5c884462216d (patch)
treeb8b754b8a5e38044892f785a13722ae750fdb487 /struct.c
parent7bfa50a6dee2d90c564774c2e7673048ef179708 (diff)
downloadtxr-ce3623c412b23252b7720e4fb8cc5c884462216d.tar.gz
txr-ce3623c412b23252b7720e4fb8cc5c884462216d.tar.bz2
txr-ce3623c412b23252b7720e4fb8cc5c884462216d.zip
ffi: alignment bug in undimensioned arrays.
Because the varray behavior for undimensioned arrays was introduced in dubious commit e0037c806d24004a7b074367b8db15620e8c0e54 in 2017, which used make_ffi_type_pointer to register the type, claiming that the C representation is pointer (which was not true in that commit, nor ever since). As a result, though, undimensioned arrays received the alignment of pointers, rather than deriving it from the element type. Thus (array char) has 4 or 8 byte alignment whereas (array 4 char) correctly has 1 byte alignment. * ffi.c (ffi_type_compile): Use make_ffi_type_array for the two-element array syntax, just like for the dimensioned case with three elements. Then override some of the functions with the varray versions. * tests/017/ffi-misc.tl: Fix the test case which exposed this. In the type (struct flex (a char) (b (zarray char)), the array b must be at offset 1. I didn't notice that the offset of 4 being confirmed by the test case was wrong, but this showed up when running the test case on a platform with 8 byte pointers.
Diffstat (limited to 'struct.c')
0 files changed, 0 insertions, 0 deletions