/* GCC uses 8-byte loads and register passing even though sizeof = 6 */
typedef struct __attribute__((__packed__))
{
unsigned chr :16;
unsigned loc :32;
} GENOME_LOC_TYPE_2;
//#define GENOME_LOC_TYPE GENOME_LOC_TYPE_1
#define GENOME_LOC_TYPE GENOME_LOC_TYPE_2
static __attribute__((__noclone__,__noinline__))
int f(GENOME_LOC_TYPE x)
{
return x.loc;
}
GENOME_LOC_TYPE h;
GENOME_LOC_TYPE *g =&h;
int
main()
{
printf ("%d %d\n", sizeof (GENOME_LOC_TYPE),
__alignof__(GENOME_LOC_TYPE));
return f(*g);
}
Both definitions have a (sizeof = 6, alignof = 1) but GCC loads the second
with an 8-byte load. It's really an ugly bug if I understood it correctly,
because I would have expected the second struct to have sizeof = 8. The two
final bytes are not padding, they are what's left of the unsigned int from
which the bitfields are carved. If that were the correct fix for the bug,
it would be a change to the ABI.