This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Alignment bug in 2.96?
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Alignment bug in 2.96?
- From: "H . J . Lu" <hjl at valinux dot com>
- Date: Thu, 8 Jun 2000 16:19:12 -0700
On Linux/ia32, with gcc 2.95.2, I got
# gcc -O2 foo.c
# ./a.out
size of x: 32
size of x.yy: 16
Aligment of x: 0
Aligment of x.yy: 0
With gcc 2.96,
# gcc -O2 foo.c
# ./a.out
size of x: 24
size of x.yy: 16
Aligment of x: 4
Aligment of x.yy: 12
zsh: 3352 abort ./a.out
It seems that __attribute__ ((aligned (16))) doesn't work at all
with gcc 2.96.
--
H.J. Lu (hjl@gnu.org)
---
struct foo {
long x;
long y;
long z;
} __attribute__ ((aligned (16)));
struct bar
{
char dummy [8];
struct foo yy __attribute__ ((aligned (16)));
};
struct bar x;
int
main ()
{
printf ("size of x: %d\n", sizeof (x));
printf ("size of x.yy: %d\n", sizeof (x.yy));
printf ("Aligment of x: %d\n", ((unsigned int) (&x)) & 15);
printf ("Aligment of x.yy: %d\n", ((unsigned int) (&x.yy)) & 15);
if ((((unsigned int) (&x.yy)) & 15) != 0)
abort ();
return 0;
}