Re: Where attribute((aligned)) is allowed to decrease alignment

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

 



Hi!

On Fri, Jun 13, 2025 at 06:52:19PM +0100, Tom V wrote:
> I have been trying to work out what all the rules are for where
> attribute((aligned(x))) can be used and where it can decrease alignment
> and where it can only increase it.

As the documentation says:
     When used on a struct, or struct member, the 'aligned' attribute
     can only increase the alignment; in order to decrease it, the
     'packed' attribute must be specified as well.  When used as part of
     a typedef, the 'aligned' attribute can both increase and decrease
     alignment, and specifying the 'packed' attribute generates a
     warning.

Where in memory the thing ends up (on the stack, for example) is neither
here nor there.  This stuff is at the language-level, not twenty or
thirty abstractions lower :-)

What you call "pointer target" is not clear, not to me at least.  This
seems to be the core of your doubts.


Segher



[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