This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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: aligned attribute


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.


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