]> Savannah Git Hosting - gnulib.git/commitdiff
alignof: port to strict C23
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 15 Jan 2023 01:48:18 +0000 (17:48 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 15 Jan 2023 01:48:54 +0000 (17:48 -0800)
Problem reported by Khem Raj in:
https://lists.gnu.org/r/bug-gnulib/2023-01/msg00111.html
* lib/alignof.h (alignof_slot) [!__cplusplus]: Use C23-style alignof.
* modules/alignof (Depends-on): Add stdalign.

ChangeLog
lib/alignof.h
modules/alignof

index 0900c54c1d75c9f84b0d3f5a52584c99f2b16435..fa684131db44f0e9fcfa7a657f1aae83d203fac4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2023-01-14  Paul Eggert  <eggert@cs.ucla.edu>
 
+       alignof: port to strict C23
+       Problem reported by Khem Raj in:
+       https://lists.gnu.org/r/bug-gnulib/2023-01/msg00111.html
+       * lib/alignof.h (alignof_slot) [!__cplusplus]: Use C23-style alignof.
+       * modules/alignof (Depends-on): Add stdalign.
+
        test-framework-sh: work around AIX 7.2 diff bugs
        * tests/init.sh (compare_dev_null_): Run diff in the C locale.
        AIX 7.2 diff messes up in UTF-8 locales; for example,
index 505ad97aa413bb76a5e30abd221e3ffdac36832e..2ded1c788482f402bd39b249faa10077662cd8e3 100644 (file)
 /* alignof_slot (TYPE)
    Determine the alignment of a structure slot (field) of a given type,
    at compile time.  Note that the result depends on the ABI.
-   This is the same as alignof (TYPE) and _Alignof (TYPE).
+   This is the same as alignof (TYPE).
    Note: The result cannot be used as a value for an 'enum' constant,
    due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc.  */
 #if defined __cplusplus
   template <class type> struct alignof_helper { char __slot1; type __slot2; };
 # define alignof_slot(type) offsetof (alignof_helper<type>, __slot2)
 #else
-# define alignof_slot(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
+# define alignof_slot(type) alignof (type)
 #endif
 
 /* alignof_type (TYPE)
index 4345eaca12b4f75c45b8c73b7d3a9f448a27ad09..c78ab4a3c531243aca1eede9332581ef23c7c2d6 100644 (file)
@@ -5,6 +5,7 @@ Files:
 lib/alignof.h
 
 Depends-on:
+stdalign
 
 configure.ac: