summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2023-01-14 17:48:18 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2023-01-14 17:48:54 -0800
commit2d404c7dd974cc65f894526f4a1b76bc1dcd8d82 (patch)
treeb82d0f3580264eed5c1a671dd345a30ad2957a2b
parent2647256a786c5900897fc15130688991503dae25 (diff)
downloadgnulib-2d404c7dd974cc65f894526f4a1b76bc1dcd8d82.tar.gz
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.
-rw-r--r--ChangeLog6
-rw-r--r--lib/alignof.h4
-rw-r--r--modules/alignof1
3 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 0900c54c1d..fa684131db 100644
--- 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,
diff --git a/lib/alignof.h b/lib/alignof.h
index 505ad97aa4..2ded1c7884 100644
--- a/lib/alignof.h
+++ b/lib/alignof.h
@@ -22,14 +22,14 @@
/* 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)
diff --git a/modules/alignof b/modules/alignof
index 4345eaca12..c78ab4a3c5 100644
--- a/modules/alignof
+++ b/modules/alignof
@@ -5,6 +5,7 @@ Files:
lib/alignof.h
Depends-on:
+stdalign
configure.ac: