From 2d404c7dd974cc65f894526f4a1b76bc1dcd8d82 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 14 Jan 2023 17:48:18 -0800 Subject: [PATCH] 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. --- ChangeLog | 6 ++++++ lib/alignof.h | 4 ++-- modules/alignof | 1 + 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 + 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 struct alignof_helper { char __slot1; type __slot2; }; # define alignof_slot(type) offsetof (alignof_helper, __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: -- 2.37.2