On alignment
Jason Merrill
jason@redhat.com
Tue Apr 22 18:46:00 GMT 2003
On Tue, 22 Apr 2003 17:04:38 +0100 (BST), Nicola Pero <nicola@brainstorm.co.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@redhat.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
More information about the Gcc
mailing list