[Bug middle-end/87524] New: inconsistent handling of attribute aligned between types and variables
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Oct 4 20:02:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87524
Bug ID: 87524
Summary: inconsistent handling of attribute aligned between
types and variables
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
When multiple instances of attribute aligned are applied to the declaration of
a variable the most restrictive instance wins.
But when multiple instances of attribute aligned are applied to the definition
of a type it's the last one that wins.
The attribute should have the same effect on all entities it applies to, i.e.,
functions, types, and variables.
$ cat x.c && gcc -S -Wall -fdump-tree-optimized=/dev/stdout x.c
#define A(N) __attribute__ ((aligned (N)))
void f0 (void)
{
A (2) A(4) char c4;
_Static_assert (_Alignof (c4) == 4, "_Alignof (c4) == 4");
}
void g0 (void)
{
A (4) A (2) char c4;
_Static_assert (_Alignof (c4) == 4, "_Alignof (c4) == 4");
}
void f1 (void)
{
typedef A (2) A (4) char C4;
_Static_assert (_Alignof (C4) == 4, "_Alignof (C4) == 4");
}
void g1 (void)
{
typedef A (4) A (2) char C4;
_Static_assert (_Alignof (C4) == 4, "_Alignof (C4) == 4");
}
x.c: In function ‘g1’:
x.c:25:3: error: static assertion failed: "_Alignof (C4) == 4"
25 | _Static_assert (_Alignof (C4) == 4, "_Alignof (C4) == 4");
| ^~~~~~~~~~~~~~
More information about the Gcc-bugs
mailing list