Thanks. Now to add to my confusion, on my system __alignof(long
double) returns 16, which I presume means that all allocation,
static, dynamic and automatic for long double objects are 16 byte
aligned.
On Dec 20, 2006, at 8:37 AM, Andrew Haley wrote:
Maurizio Vitale writes:
But when I move to my real application (an event-driven simulator) I
get stack allocated objects on 8-byte boundaries.
Now, my reading of the documentation is that the aligned attribute
(when used for types, as in the example I gave) applies to all
allocations (global, auto and heap). Is there any place where it is
said otherwise? Regardless of the documentation, what does the
implementation do?
You can't get alignment any greater than the alignment of the stack
pointer. The alignment of the stack pointer is defined the the ABI of
the particular target you're using. I think it's 16 for x86
processors, but the processor itself doesn't enforce that: it varies
across operating systems and processor variants.
This lead me to believe that every time a variable of type S is
allocated, the requested alignment is used (modulo linker
limitations of above).
Sure, but that only really applies to statically allocated objects. I
guess no-one appreciated that someone might want to use it for
auto variables.
Andrew.