# HG changeset patch # User Paul Eggert # Date 1364611633 25200 # Node ID 7524d97ae56f27b929fb8ea005242fc33b6f0e5e # Parent 5a51fb7777a9950502965a043a70bd6ca5e0498b stdalign: port to stricter ISO C11 ISO C11 says that _Alignof's operand must be a parenthesized type. Problem reported by Eli Zaretskii in . * doc/posix-headers/stdalign.texi (stdalign.h): Document this. * m4/stdalign.m4 (gl_STDALIGN_H): Don't use _Alignof (expr). diff -r 5a51fb7777a9 -r 7524d97ae56f ChangeLog --- a/ChangeLog Tue Mar 19 09:08:47 2013 -0700 +++ b/ChangeLog Fri Mar 29 19:47:13 2013 -0700 @@ -1,3 +1,12 @@ +2013-03-29 Paul Eggert + + stdalign: port to stricter ISO C11 + ISO C11 says that _Alignof's operand must be a parenthesized type. + Problem reported by Eli Zaretskii in + . + * doc/posix-headers/stdalign.texi (stdalign.h): Document this. + * m4/stdalign.m4 (gl_STDALIGN_H): Don't use _Alignof (expr). + 2013-03-21 Paul Eggert sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin diff -r 5a51fb7777a9 -r 7524d97ae56f doc/posix-headers/stdalign.texi --- a/doc/posix-headers/stdalign.texi Tue Mar 19 09:08:47 2013 -0700 +++ b/doc/posix-headers/stdalign.texi Fri Mar 29 19:47:13 2013 -0700 @@ -25,6 +25,13 @@ Portability problems not fixed by Gnulib: @itemize @item +In ISO C11, the operand of @code{alignof}/@code{_Alignof} must be a +parenthesized type. Recent versions of GCC support an extension in +which the operand can also be a unary expression, as with +@code{sizeof}. We don't know of any compilers that support +@code{alignof}/@code{_Alignof} without also supporting this extension; +if you find one please let us know. +@item @code{_Alignas} and @code{alignas} are not always supported; on platforms lacking support, the macro @code{__alignas_is_defined} is not defined. diff -r 5a51fb7777a9 -r 7524d97ae56f m4/stdalign.m4 --- a/m4/stdalign.m4 Tue Mar 19 09:08:47 2013 -0700 +++ b/m4/stdalign.m4 Fri Mar 29 19:47:13 2013 -0700 @@ -33,8 +33,9 @@ #if \ (__GNUC__ || __IBMC__ || __IBMCPP__ \ || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER) - int alignas (8) alignas_int = 1; - char test_alignas[_Alignof (alignas_int) == 8 ? 1 : -1]; + struct alignas_test { char c; char alignas (8) alignas_8; }; + char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 + ? 1 : -1]; #endif ]])], [gl_cv_header_working_stdalign_h=yes],