https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64655

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Adrien Guinet from comment #7)
> From my understanding of
> https://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html, the "aligned"
> attribute inside a structure aligns the object inside this structure, and
> nothing more, as the example says:
> 
> "You can also specify the alignment of structure fields. For example, to
> create a double-word aligned int pair, you could write:
> 
>           struct foo { int x[2] __attribute__ ((aligned (8))); };
>           
> 
> This is an alternative to creating a union with a double member that forces
> the union to be double-word aligned. "
> 
> If I create a union, there is no alignment information. Anyway, I'd be happy
> to read the official definition if it is specified somewhere!

Your understanding is wrong.  If certain field requires some alignment, then
obviously the whole structure requires that alignment too, otherwise the field
would not be aligned as requested (unless the struct is __attribute__((packed))
of course).  Just try to print __alignof__ (struct A), you'll see it is 32.
Anyway, please stop reopening, GCC bugzilla is for reporting compiler bugs, not
a place to learn C and/or the GCC extensions.  Please try gcc-help mailing
list.

Reply via email to