[PATCH] Define libc_max_align_t
Paul Eggert
eggert@cs.ucla.edu
Thu Apr 2 05:00:00 GMT 2015
On 04/01/2015 03:01 PM, Andreas Schwab wrote:
>> +typedef struct {
>> >+ long long ll __attribute__ ((__aligned__ (__alignof__ (long long))));
>> >+ long double ld __attribute__ ((__aligned__ (__alignof__ (long double))));
>> >+} libc_max_align_t;
> Why aren't the attributes no-ops?
I wondered the same thing and reread the relevant sections of the C11 committee
draft of Apri 12, 2011. It's a subtle point. max_align_t is not defined to be a
type whose alignment is equal to the maximum of the alignments of all the
standard types. Instead, it is defined to be a type whose alignment "is as
great as is supported by the implementation in all contexts", which is not
necessarily the same thing. As there doesn't seem to be any portable way to
define max_align_t on a pre-C11 compiler (defining a union whose members include
all standard types doesn't seem to suffice), I suppose GCC uses those attributes
as a nonportable way to do the job. If so, glibc might as well be compatible
with GCC.
More information about the Libc-alpha
mailing list