C11 max_align_t does not work with both base system clang and ports clang (clang has those defined under lib/Headers but we don't install them, while we do install GCC's fixed headers for GCC in ports, e.g. /usr/local/lib/gcc49/gcc/x86_64-portbld-freebsd8.4/4.9.2/include/stddef.h). FreeBSD already defines C11 additions in /usr/include/stdlib.h, and we should do the same for max_align_t. I copy-pasted clang's implementation to /usr/include/stddef.h and everything works fine: #if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L typedef struct { long long __clang_max_align_nonce1 __attribute__((__aligned__(__alignof__(long long)))); long double __clang_max_align_nonce2 __attribute__((__aligned__(__alignof__(long double)))); } max_align_t; #endif GCC's implementation queries for defined(__STDC_VERSION__) and defined(__cplusplus); the struct is the same.
One more issue needs to be fixed for libc++ in base if we make the change: In cstddef, the latest version contains #if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) // Re-use the compiler's <stddef.h> max_align_t where possible. using ::max_align_t; #else typedef long double max_align_t; #endif which is hacky, but the version we use is even worse typedef long double max_align_t; , which is bad. After we updated /usr/include/stddef.h, we should patch our libc++ to say just using ::max_align_t; in C++11 mode (exactly what libstdc++ does).
(In reply to lichray from comment #1) I think the more reliable solution would be to let our <stddef.h>: #define __CLANG_MAX_ALIGN_T_DEFINED That way it's impossible for the logic on our side and libc++ to conflict.
Dup of PR210890, already closed.
Correctly mark as duplicate *** This bug has been marked as a duplicate of bug 210890 ***