https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81566
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|invalid attribute aligned |[4.9/5/6/7/8 Regression] |accepted on functions |invalid attribute aligned | |accepted on functions --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- The handle_aligned_attribute() function in c-family/c-attribs.c tries to detect and reject attribute aligned on declarations that attempt to relax a function's alignment (see the second if statement below) but that code is never reached apparently because of the test immediately before it. That test was added in r192199 (in GCC 4.9) that added C++ 11 alignas support. Prior to that GCC rejected a function declaration with conflicting attribute aligned. I cannot find any tests for the ineffective code in the test suite. else if (DECL_USER_ALIGN (decl) && DECL_ALIGN (decl) > (1U << i) * BITS_PER_UNIT) /* C++-11 [dcl.align/4]: When multiple alignment-specifiers are specified for an entity, the alignment requirement shall be set to the strictest specified alignment. This formally comes from the c++11 specification but we are doing it for the GNU attribute syntax as well. */ *no_add_attrs = true; else if (TREE_CODE (decl) == FUNCTION_DECL && DECL_ALIGN (decl) > (1U << i) * BITS_PER_UNIT) { if (DECL_USER_ALIGN (decl)) error ("alignment for %q+D was previously specified as %d " "and may not be decreased", decl, DECL_ALIGN (decl) / BITS_PER_UNIT); else error ("alignment for %q+D must be at least %d", decl, DECL_ALIGN (decl) / BITS_PER_UNIT); *no_add_attrs = true; }