According to 3.11.2 in the C++11 standard max_align_t should be inside the std namespace (i.e. the text talks about use of alignof(std::max_align_t)). GCC only provides ::max_align_t, though: % cat main.cpp #include <cstddef> int main() { return alignof(std::max_align_t); } % /opt/gcc-4.7.2/bin/g++ -Wall -std=c++11 -o test main.cpp main.cpp: In function ‘int main()’: main.cpp:4:20: error: ‘max_align_t’ is not a member of ‘std’ main.cpp:4:20: note: suggested alternative: In file included from /home/.opt/gcc-4.7.2/bin/../lib/gcc/x86_64-suse-linux-gnu/4.7.2/../../../../include/c++/4.7.2/cstddef:44:0, from main.cpp:1: /home/.opt/gcc-4.7.2/bin/../lib/gcc/x86_64-suse-linux-gnu/4.7.2/include/stddef.h:426:3: note: ‘max_align_t’ % /opt/gcc-4.8-snapshot/bin/g++ -Wall -std=c++11 -o test main.cpp main.cpp: In function ‘int main()’: main.cpp:4:20: error: ‘max_align_t’ is not a member of ‘std’ return alignof(std::max_align_t); ^ main.cpp:4:20: note: suggested alternative: In file included from /home/.opt/gcc-4.8-snapshot/include/c++/4.8.0/cstddef:44:0, from main.cpp:1: /home/.opt/gcc-4.8-snapshot/lib/gcc/x86_64-suse-linux-gnu/4.8.0/include/stddef.h:425:3: note: ‘max_align_t’ } max_align_t; ^
<cstddef> just hasn't been updated since max_align_t was added to <stddef.h>
Mine.
Fixed for 4.9.0. If somebody is interested in 4.8.x too, backporting the patch should not be a big deal.
The fix introduces another problem. Whenever '__need_size_t' is defined prior to the inclusion of <cstddef>, the type 'max_align_t' will not have been defined. This inevitably causes a compiler error: #define __need_size_t #include <cstddef> int main( void ) { return 0; } This happens on Mac OS X 10.9. In my case it got triggered by including <gmp.h>. Presumably this bug also occurs when #defining the other '__need_*' macros.
I would propose adding something like #ifdef _GCC_MAX_ALIGN_T ... #endif around the 'using' declaration. (Though I really have no idea whatsoever off gcc internals...)
(In reply to Jobst.Ziebell from comment #4) > Presumably this bug also occurs when #defining the other '__need_*' macros. Which user code should never be doing anyway. GMP is broken (and already fixed upstream). This is documented at http://gcc.gnu.org/gcc-4.9/porting_to.html and isn't going to be changed to accomodate broken libraries.