[Bug middle-end/20794] [4.0/4.1 Regression] Miscompilation with __attribute ((aligned))

jakub at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Apr 6 15:05:00 GMT 2005


------- Additional Comments From jakub at gcc dot gnu dot org  2005-04-06 15:05 -------
Doesn't need to be in struct, and the requested alignment must be bigger
than sizeof (int) to reproduce.
extern void abort (void);

typedef int T __attribute__((aligned (8)));
T a[2];
void *p[2];

int
main (void)
{
  p[0] = &a[0];
  p[1] = &a[1];
  if (p[0] == p[1])
    abort ();
  return 0;
}
fails as well.

Note that the requested alignment is apparently honored by neither GCC 3.4 and
earlier in C, nor in G++ (3.4 as well as 4.0) for the individual array members,
only the whole array is aligned as if the attribute was present on the array
itself, not on the member type.

So we probably first need to answer whether that layout is correct or if we want
an ABI change here.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20794



More information about the Gcc-bugs mailing list