问题
I have been trying to find out exactly what is the required alignment of long double in x86-64 mac and linux. I have found various different things that hint at different requirements, but can't find an authorative source.
I am finding on Mac OS X, gcc will generate code sometimes which copy long doubles using movaps, which requires 16-byte alignment. But clang does not and gcc is very old, so maybe this is just an old bug which is not going to get fixed?
回答1:
The Linux x86_64 ABI specifies that long double shall be 16 byte aligned. This is different from the 32-bit x86 Linux ABI, which specifies that long double is only 4 byte aligned (suboptimal on current CPU's but an historical artifact).
I'm not sure about the Mac OSX x86 ABI, but it would surprise me if they'd retain such historical baggage. Hence my guess would be 16-byte alignment.
来源:https://stackoverflow.com/questions/12938828/what-is-the-required-alignment-of-long-double-in-64-bit-linux-mac-and-others