Just for the record: $ cat sizer.c #include <stdio.h> int main() { printf(" sizeof(long long) = %2u __alignof__(long long) = %2u\n", (unsigned) sizeof(long long), (unsigned) __alignof__(long long)); printf(" sizeof(struct {long long N;}) = %2u __alignof__(struct {long long N;}) = %2u\n", (unsigned) sizeof(struct {long long N;}), (unsigned) __alignof__(struct {long long N;})); return 0; } $ gcc -Wall -o sizer sizer.c $ ./sizer sizeof(long long) = 8 __alignof__(long long) = 8 sizeof(struct {long long N;}) = 8 __alignof__(struct {long long N;}) = 4
Yes, this was a surprise. I knew that structures can cause padding to be introduced, and arrays can have higher alignment constraints than their elements. But lowering alignment constraints? Is __alignof__() telling the truth here? Or is it giving a truthful less-than-useful answer? (Because what matters to MoarVM is the alignment of, and therefor padding needed for, structure members) Nicholas Clark