GIBaseInfo/GIBaseInfoStack bitfield definition doesn't match on 16-bit-aligned-pointer systems
Building glib-2.80.1 on m68k-linux-gnu with GCC 14.1.0 fails:
../glib-2.80.1/glib/gmacros.h:871:31: error: static assertion failed: "Expression evaluates to false"
../glib-2.80.1/girepository/girepository-private.h:67:1: note: in expansion of macro ‘G_STATIC_ASSERT’
67 | G_STATIC_ASSERT (sizeof (GIBaseInfo) == sizeof (GIBaseInfoStack));
| ^~~~~~~~~~~~~~~
Structs GIBaseInfo
and GIBaseInfoStack
are intended to have the same layout. However, GIBaseInfo
ends with:
uint32_t offset;
uint32_t type_is_embedded : 1;
void *padding[6];
And GIBaseInfoStack
has:
uint32_t dummy2[2];
void *dummy3[6];
On m68k, pointers only need to be aligned on 2-byte boundaries, so GCC correctly allocates 16 bits rather than 32 bits for the bitfield.
I suspect the author of this was thinking that uint32_t type_is_embedded : 1
means "allocate a uint32_t
, then take bits from that" - it doesn't, it just happens to work because uint32_t is (usually) defined as unsigned int, which is a valid bitfield type.
How about putting unsigned int type_is_embedded : 1;
in both definitions?