https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65685
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org Known to fail| |4.5.3, 4.8.3, 4.9.3, 5.3.0, | |6.0 --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- Still fails with the latest trunk and always has. Below is a slightly modified test case to compare the behavior between C++11 (using alignas), C11 (using _Alignas), and prior standards (using GCC's __attribute__ aligned). As expected, GCC in C11 mode rejects the _Alignas specifier iB with the error below: u.cpp:10:32: error: ‘_Alignas’ specifiers cannot reduce alignment of ‘a’ Both gcc and g++ silently accept but ignore __attribute__ aligned in B (it would be nice if they issued a warning to point that out). Finally, as noted, g++ in C++11 mode silently accepts the code: $ cat u.cpp && /home/msebor/build/gcc-trunk-svn/gcc/xgcc -B/home/msebor/build/gcc-trunk-svn/gcc -S -Wall -Wextra -Wpedantic -std=c++11 -xc++ u.cpp #if __cplusplus >= 201103L # define Align(N) alignas (N) #elif __STDC_VERSION__ >= 201112L # define Align(N) _Alignas (N) #else # define Align(N) __attribute__ ((aligned (N))) #endif typedef struct A { Align (8) char c; } A; typedef struct B { Align (1) A a; } B; #define A(e) typedef char Assert [1 - 2 * !(e)] A (__alignof__ (A) == 8); A (__alignof__ (B) == 8);