bug-gnulib
[Top][All Lists]
Advanced

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

stdalign: Fix test failures on 32-bit platforms with clang versions < 8


From: Bruno Haible
Subject: stdalign: Fix test failures on 32-bit platforms with clang versions < 8
Date: Thu, 20 Aug 2020 23:57:01 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; )

With
  - clang 4.0.0, 5.0.2, 6.0.1, 7.0.1 on Linux/x86,
  - clang 3.4 on minix
I'm seeing these compilation errors:

../../gltests/test-stdalign.c:70:1: error: static_assert failed "verify 
(alignof (int64_t) == offsetof (int64_t_helper, slot2))"
CHECK_STATIC (int64_t);
^~~~~~~~~~~~~~~~~~~~~~
../../gltests/test-stdalign.c:57:3: note: expanded from macro 'CHECK_STATIC'
  verify (alignof (type) == offsetof (type##_helper, slot2)); \
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gltests/verify.h:289:20: note: expanded from macro 'verify'
# define verify(R) _GL_VERIFY (R, "verify (" #R ")", -)
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gltests/verify.h:229:41: note: expanded from macro '_GL_VERIFY'
# define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC)
                                        ^               ~
../../gltests/test-stdalign.c:73:1: error: static_assert failed "verify 
(alignof (double) == offsetof (double_helper, slot2))"
CHECK_STATIC (double);
^~~~~~~~~~~~~~~~~~~~~
../../gltests/test-stdalign.c:57:3: note: expanded from macro 'CHECK_STATIC'
  verify (alignof (type) == offsetof (type##_helper, slot2)); \
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gltests/verify.h:289:20: note: expanded from macro 'verify'
# define verify(R) _GL_VERIFY (R, "verify (" #R ")", -)
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gltests/verify.h:229:41: note: expanded from macro '_GL_VERIFY'
# define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC)
                                        ^               ~
2 errors generated.

Similarly on AIX with IBM xlc 16, which presents itself as a variant of
clang 4.0.1:

../../gltests/test-stdalign.c:73:1: error: static_assert failed "verify 
(alignof (double) == offsetof (double_helper, slot2))"
CHECK_STATIC (double);
^~~~~~~~~~~~~~~~~~~~~
../../gltests/test-stdalign.c:57:3: note: expanded from macro 'CHECK_STATIC'
  verify (alignof (type) == offsetof (type##_helper, slot2)); \
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gltests/verify.h:289:20: note: expanded from macro 'verify'
# define verify(R) _GL_VERIFY (R, "verify (" #R ")", -)
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gltests/verify.h:229:41: note: expanded from macro '_GL_VERIFY'
# define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC)
                                        ^               ~
1 error generated.

This patch fixes these failures.


2020-08-20  Bruno Haible  <bruno@clisp.org>

        stdalign: Fix test failures on 32-bit platforms with clang versions < 8.
        * lib/stdalign.in.h (_Alignof): For clang versions < 8, use the same
        workaround as for GCC versions < 4.9.

diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h
index ad1bd00..867053f 100644
--- a/lib/stdalign.in.h
+++ b/lib/stdalign.in.h
@@ -54,10 +54,12 @@
 #undef _Alignof
 
 /* GCC releases before GCC 4.9 had a bug in _Alignof.  See GCC bug 52023
-   <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.  */
+   <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.
+   clang versions < 8.0.0 have the same bug.  */
 #if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
      || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
-         && !defined __clang__))
+         && !defined __clang__) \
+     || (defined __clang__ && __clang_major__ < 8))
 # ifdef __cplusplus
 #  if 201103 <= __cplusplus
 #   define _Alignof(type) alignof (type)




reply via email to

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