https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86508
Bug ID: 86508
Summary: missing -Wattributes on an ignored attempt to reduce
struct alignment
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: ---
GCC silently accepts the defintion of the struct below but ignores the
attribute because it attempts to relax its alignment.
$ cat x.c && gcc -S -Wall -Wextra -m32 x.c
#define A 2
struct __attribute__ ((aligned (A))) S
{
int *p;
} s;
_Static_assert (_Alignof (s) == A, "#1");
x.c:8:1: error: static assertion failed: "#1"
_Static_assert (_Alignof (s) == A, "#1");
^~~~~~~~~~~~~~
GCC does diagnose the failed attempt with the _Alignas specifier, though G++
not only fails to diagnose it but also honors it and decrease the struct's
alignment.
Intel ICC issues a helpful message here:
warning #1366: a reduction in alignment without the "packed" attribute is
ignored
struct __attribute__ ((aligned (A))) S