This is the mail archive of the gcc@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: On alignment


On Tue, 22 Apr 2003 17:04:38 +0100 (BST), Nicola Pero <nicola at brainstorm dot co dot uk> wrote:

> At runtime, the ObjC runtime library has information about the struct -
> the type of each member.  At the moment, it loops on the struct members,
> and uses __alignof__ on each of them to get the alignment of that member
> inside the struct (then, can read/write the struct members).  As far as I
> understand from this discussion, this doesn't work any longer.

If you actually take __alignof the member, this should work fine.  If you
do __alignof the type, you will get the larger number.

On Tue, 22 Apr 2003 17:19:28 +0100, Andrew Haley <aph at redhat dot com> wrote:

> It's rather scary.  It means, for example, that
>
> template<class T> void copy (T *a, T *b)
> {
>   if (__alignof__ (T) >= 8)
>     copy_by_dwords (a, b);
>   else
>     copy_by_bytes (a, b);
> }    
>
> won't do what is expected when applied to a member of a struct.  I
> suppose we get away with this because the x86 never generates
> alignment traps in such cases.

Exactly.  A STRICT_ALIGNMENT target wouldn't do this sort of thing.

Jason


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