Simon Josefsson wrote: > The alignof module seems to have problems: > > j...@mocca:~/src/gnulib master$ gnulib-tool --test --with-tests alignof > ... > ../../gltests/test-alignof.c:41: error: negative width in bit-field > ‘verify_error_if_negative_size__’
I reproduce with all versions of gcc since 3.1, on x86, when -malign-double is not specified. offsetof (struct { char slot1; double slot2; }, slot2) is 4 by default, but 8 when -malign-double is specified. Whereas __alignof__ (double) is always 8 on x86; this is even part of the GCC test suite [1]. [2] says: "It turns out that the alignment of a type can differ from the alignment of a field of that type. In particular, on x86 alignof(double) is 8, but a double as a field has alignment 4." I'm not sure which one we should use in gnulib. Probably the "alignment of a field of that type" semantics, because that's what we use alignof for? Bruno [1] https://www.codeblog.org/viewsrc/gcc-4.1.0/gcc/testsuite/g++.old-deja/g++.abi/align.C [2] http://gcc.gnu.org/ml/java-patches/2003-q2/msg00098.html