https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89950
Bug ID: 89950 Summary: attribute aligned ignored with attribute vector_size Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- When attribute aligned appears in conjunction with attribute vector_size on the same declaration and when the former specifies a different alignment than the latter attribute implies, the alignment specified by the former attribute is ignored. However, when attribute aligned is specified on a vector (re)declaration without attribute vector_size, the alignment is honored. $ cat z.c && gcc -O2 -S -Wall z.c void f (void) { typedef __attribute__ ((vector_size (1024))) int Vec_1k; typedef __attribute__ ((aligned (256))) Vec_1k V; _Static_assert (__alignof__ (V) == 256); // passes _Static_assert (__builtin_has_attribute (V, aligned (256))); // passes V v; _Static_assert (__alignof__ (v) == 256); // passes _Static_assert (__builtin_has_attribute (v, aligned (256))); // passes } void g (void) { typedef __attribute__ ((aligned (256), vector_size (1024))) int V; _Static_assert (__alignof__ (V) == 256); // fails _Static_assert (__builtin_has_attribute (V, aligned (256))); // fails V v; _Static_assert (__alignof__ (v) == 256); // fails _Static_assert (__builtin_has_attribute (v, aligned (256))); // fails } z.c: In function āgā: z.c:17:3: error: static assertion failed 17 | _Static_assert (__alignof__ (V) == 256); // fails | ^~~~~~~~~~~~~~ z.c:18:3: error: static assertion failed 18 | _Static_assert (__builtin_has_attribute (V, aligned (256))); // fails | ^~~~~~~~~~~~~~ z.c:21:3: error: static assertion failed 21 | _Static_assert (__alignof__ (v) == 256); // fails | ^~~~~~~~~~~~~~ z.c:22:3: error: static assertion failed 22 | _Static_assert (__builtin_has_attribute (v, aligned (256))); // fails | ^~~~~~~~~~~~~~