Re: are statically allocated structs always aligned to a machine word on x86/x86_64?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23 August 2015 at 14:49, Jonathan Wakely wrote:
> On 23 August 2015 at 12:05, Segher Boessenkool wrote:
>> On Sun, Aug 23, 2015 at 12:15:56AM +0100, Jonathan Wakely wrote:
>>> because alignments must be a power of 2.
>>
>> That is true in C++, but not true in C or even POSIX afaics?
>
> C11 §6.2.8
>
> "Every valid alignment value shall be a nonnegative integral power of two."

Anyway, the point is that John's assumption is wrong, you can have
alignments larger than one and smaller than sizeof(int) in which case
objects with those alignments don't have to be word-aligned.

If you want to know whether an object will be word-aligned then use
the alignof keyword, rather than incorrect assumptions.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux