From: Paul Eggert <eggert@cs.ucla.edu>
To: Khem Raj <raj.khem@gmail.com>
Cc: bug-gnulib@gnu.org
Subject: Re: [PATCH v2] Define alignof_slot using _Alignof when using C11 or newer
Date: Sat, 14 Jan 2023 17:51:59 -0800 [thread overview]
Message-ID: <c3943fc1-58af-0bf0-7005-77aaeea8c865@cs.ucla.edu> (raw)
In-Reply-To: <20230115012007.2175339-1-raj.khem@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 751 bytes --]
On 2023-01-14 17:20, Khem Raj wrote:
> +/* 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>.
> + clang versions < 8.0.0 have the same bug. */
> +#elif (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
> + || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
> + && !defined __clang__) \
> + || (defined __clang__ && __clang_major__ < 8))
We already have two copies of that stuff elsewhere (in lib/stdalign.in.h
and m4/stdalign.m4), for reasons that currently escape me. Let's not
balloon the number of copies to three.
I installed the attached smaller patch which should do the trick for C.
Is there a similar problem with C++.
[-- Attachment #2: 0001-alignof-port-to-strict-C23.patch --]
[-- Type: text/x-patch, Size: 2215 bytes --]
From 2d404c7dd974cc65f894526f4a1b76bc1dcd8d82 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
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 <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:
--
2.37.2
next prev parent reply other threads:[~2023-01-15 1:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-15 1:20 [PATCH v2] Define alignof_slot using _Alignof when using C11 or newer Khem Raj
2023-01-15 1:51 ` Paul Eggert [this message]
2023-01-15 19:52 ` Paul Eggert
2023-01-15 19:56 ` Paul Eggert
2023-01-15 23:05 ` Khem Raj
2023-01-16 17:01 ` Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c3943fc1-58af-0bf0-7005-77aaeea8c865@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=bug-gnulib@gnu.org \
--cc=raj.khem@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).