This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Define libc_max_align_t


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]