public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Maurizio Vitale <maurizio.vitale@polymath-solutions.com>
To: gcc-help@gcc.gnu.org
Subject: Re: aligned attribute
Date: Wed, 20 Dec 2006 13:52:00 -0000	[thread overview]
Message-ID: <55F3398C-978D-4471-802E-D14D4B777BEB@polymath-solutions.com> (raw)
In-Reply-To: <17801.15520.429722.620134@zebedee.pink>

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.
>
>

  reply	other threads:[~2006-12-20 13:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-20 13:28 Maurizio Vitale
2006-12-20 13:37 ` Andrew Haley
2006-12-20 13:52   ` Maurizio Vitale [this message]
2006-12-21 21:23     ` Tim Prince
2006-12-21 21:31       ` Maurizio Vitale
2006-12-22 12:02         ` Andrew Haley
2006-12-22 13:16           ` Maurizio Vitale
2006-12-21 21:21   ` Tim Prince

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55F3398C-978D-4471-802E-D14D4B777BEB@polymath-solutions.com \
    --to=maurizio.vitale@polymath-solutions.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).