Signed-off-by: Khem Raj <raj.k...@gmail.com> --- meta/recipes-devtools/m4/m4-1.4.19.inc | 1 + ...lot-using-_Alignof-when-using-C11-or.patch | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 meta/recipes-devtools/m4/m4/0001-Define-alignof_slot-using-_Alignof-when-using-C11-or.patch
diff --git a/meta/recipes-devtools/m4/m4-1.4.19.inc b/meta/recipes-devtools/m4/m4-1.4.19.inc index 6ee9742277..c098a4077e 100644 --- a/meta/recipes-devtools/m4/m4-1.4.19.inc +++ b/meta/recipes-devtools/m4/m4-1.4.19.inc @@ -9,6 +9,7 @@ inherit autotools texinfo ptest gettext SRC_URI = "${GNU_MIRROR}/m4/m4-${PV}.tar.gz \ file://ac_config_links.patch \ file://0001-sigsegv-Fix-build-on-ppc-musl.patch \ + file://0001-Define-alignof_slot-using-_Alignof-when-using-C11-or.patch \ " SRC_URI:append:class-target = " file://run-ptest \ file://serial-tests-config.patch \ diff --git a/meta/recipes-devtools/m4/m4/0001-Define-alignof_slot-using-_Alignof-when-using-C11-or.patch b/meta/recipes-devtools/m4/m4/0001-Define-alignof_slot-using-_Alignof-when-using-C11-or.patch new file mode 100644 index 0000000000..8757abd7a0 --- /dev/null +++ b/meta/recipes-devtools/m4/m4/0001-Define-alignof_slot-using-_Alignof-when-using-C11-or.patch @@ -0,0 +1,49 @@ +From b0fd3a58354b1f5ead891907979dfd3dd36840d5 Mon Sep 17 00:00:00 2001 +From: Khem Raj <raj.k...@gmail.com> +Date: Sat, 14 Jan 2023 14:55:03 -0800 +Subject: [PATCH] Define alignof_slot using _Alignof when using C11 or newer + +WG14 N2350 made very clear that it is an UB having type definitions +within "offsetof" [1]. This patch enhances the implementation of macro +alignof_slot to use builtin "_Alignof" to avoid undefined behavior on +when using std=c11 or newer + +clang 16+ has started to flag this [2] + +Fixes build when using -std >= gnu11 and using clang16+ [3] + +[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm +[2] https://reviews.llvm.org/D133574 +[3] https://public-inbox.org/bug-gnulib/20230114232744.215167-1-raj.k...@gmail.com/T/#u + +Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=2d404c7dd974cc65f894526f4a1b76bc1dcd8d82] +Signed-off-by: Khem Raj <raj.k...@gmail.com> +--- + lib/alignof.h | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/lib/alignof.h ++++ b/lib/alignof.h +@@ -18,19 +18,19 @@ + #define _ALIGNOF_H + + #include <stddef.h> ++#include "stdalign.h" + + /* 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), defined in +- <stdalign.h> if __alignof_is_defined is 1. ++ 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) -- 2.39.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#175953): https://lists.openembedded.org/g/openembedded-core/message/175953 Mute This Topic: https://lists.openembedded.org/mt/96291462/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-