bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] stdalign: port to stricter ISO C11


From: Paul Eggert
Subject: [PATCH] stdalign: port to stricter ISO C11
Date: Fri, 29 Mar 2013 19:48:45 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4

ISO C11 says that _Alignof's operand must be a parenthesized type.
Problem reported by Eli Zaretskii in
<http://lists.gnu.org/archive/html/emacs-devel/2013-03/msg00960.html>.
* doc/posix-headers/stdalign.texi (stdalign.h): Document this.
* m4/stdalign.m4 (gl_STDALIGN_H): Don't use _Alignof (expr).
---
 ChangeLog                       | 9 +++++++++
 doc/posix-headers/stdalign.texi | 7 +++++++
 m4/stdalign.m4                  | 5 +++--
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3843c33..768f3a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-03-29  Paul Eggert  <address@hidden>
+
+       stdalign: port to stricter ISO C11
+       ISO C11 says that _Alignof's operand must be a parenthesized type.
+       Problem reported by Eli Zaretskii in
+       <http://lists.gnu.org/archive/html/emacs-devel/2013-03/msg00960.html>.
+       * 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  <address@hidden>
 
        sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin
diff --git a/doc/posix-headers/stdalign.texi b/doc/posix-headers/stdalign.texi
index 8e34673..cad83f6 100644
--- a/doc/posix-headers/stdalign.texi
+++ b/doc/posix-headers/stdalign.texi
@@ -25,6 +25,13 @@ the types @code{double} and @code{long long} in GCC 4.7.0.
 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
address@hidden  We don't know of any compilers that support
address@hidden/@code{_Alignof} without also supporting this extension;
+if you find one please let us know.
address@hidden
 @code{_Alignas} and @code{alignas} are not always supported;
 on platforms lacking support, the
 macro @code{__alignas_is_defined} is not defined.
diff --git a/m4/stdalign.m4 b/m4/stdalign.m4
index 3d7993d..a866ff6 100644
--- a/m4/stdalign.m4
+++ b/m4/stdalign.m4
@@ -33,8 +33,9 @@ AC_DEFUN([gl_STDALIGN_H],
             #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],
-- 
1.7.11.7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]