Alignment of `complex double`
Florian Weimer
fweimer@redhat.com
Tue Jan 7 10:11:52 GMT 2025
* Jonathan Wakely via Gcc:
> On Tue, 7 Jan 2025, 03:09 M Chhapgar via Gcc, <gcc@gcc.gnu.org> wrote:
>
>> Hello,
>>
>> I am learning about memory alignment and noticed that on my x86-64 machine
>> with GCC 14, a `complex double` has a size of 16 bytes, but an alignment of
>> only 8 bytes. I am curious as to why this is.
>
>
> Because it's roughly equivalent to:
>
> double arr[2];
>
> This also has size 16 and alignment 8.
Well, the story is a bit more complicated. Array variables that are at
least 16 bytes large have 16 byte alignment. This rule does not apply
to struct members.
The x86-64 ABI currently does not specify alignment for _Complex or
_Atomic types.
Thanks,
Florian
More information about the Gcc
mailing list