[Bug tree-optimization/97164] incorrect offset on structure member where type of that member has aligned attribute
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Sep 22 12:51:44 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97164
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Reduced testcase for -O2:
typedef struct { int *a; char b[64]; } A __attribute__((aligned (64)));
struct B { A d[4]; } b;
void foo (void);
int *
bar (void)
{
struct B *h = &b;
if (h->d[1].a)
foo ();
return h->d[1].a;
}
Not really sure about the validity of the testcase (both original and reduced),
it works fine if one uses
typedef struct __attribute__((aligned (64))) A { int *a; char b[64]; } A;
instead. The problem is that above, the (anonymous) struct has different
alignment from the typedef and we end up using the type without the increased
alignment for one of those accesses.
More information about the Gcc-bugs
mailing list