This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Alignment of unions containing vector types
- From: David Robinson <drtr at enjura dot com>
- To: bug-gcc at gcc dot gnu dot org
- Date: Sat, 25 May 2002 03:38:20 -0700 (PDT)
- Subject: Alignment of unions containing vector types
Summary:
GCC 3.1 does not correctly set the alignment required for a union
containing one of the new vector types.
Version: gcc 3.1 compiled for i686-pc-linux-gnu, on Redhat 7.2, Linux
kernel 2.4.18, CPU PentiumIII-M.
The program produces:
alignof(v2si_u): 4
alignof(v2si): 8; x: 0xbffffa30
David Robinson (drtr@enjura.com)
Source:
#include <stdio.h>
#include <stdlib.h>
typedef int _v2si __attribute__ ((mode(V2SI)));
typedef union
{
_v2si v;
int i[2];
} v2si_u;
typedef union
{
_v2si v;
int i[2];
} v2si __attribute__ ((aligned(__alignof__(_v2si))));
int
main(int argc, char **argv)
{
v2si x;
printf("alignof(v2si_u): %d\n", __alignof__(v2si_u));
printf("alignof(v2si): %d; x: %p\n", __alignof__(x), &x);
exit(0);
}