From: Bruno Haible Date: Fri, 27 Jan 2023 19:35:59 +0000 (+0100) Subject: stddef: Fix test-stddef compilation error on FreeBSD 12/x86. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=668c0b8ffaece623cb0a349e129de4cadd300ff1;p=gnulib.git stddef: Fix test-stddef compilation error on FreeBSD 12/x86. * m4/stddef_h.m4 (gl_STDDEF_H): When testing for good max_align_t, use an ISO C compliant definition of _Alignof. --- diff --git a/ChangeLog b/ChangeLog index 3f7edb597b..3833faffb7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-01-27 Bruno Haible + + stddef: Fix test-stddef compilation error on FreeBSD 12/x86. + * m4/stddef_h.m4 (gl_STDDEF_H): When testing for good max_align_t, use + an ISO C compliant definition of _Alignof. + 2023-01-25 Bruno Haible Keep config.h idempotent. diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4 index c0553d6f2f..a2322ebb7e 100644 --- a/m4/stddef_h.m4 +++ b/m4/stddef_h.m4 @@ -1,4 +1,4 @@ -# stddef_h.m4 serial 12 +# stddef_h.m4 serial 13 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -22,7 +22,14 @@ AC_DEFUN_ONCE([gl_STDDEF_H], [gl_cv_type_max_align_t], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( - [[#include + [[/* On FreeBSD 12.0/x86, max_align_t defined by has + the correct alignment with the default (wrong) definition of + _Alignof, but a wrong alignment as soon as we activate an + ISO C compliant _Alignof definition. */ + #if ((defined __GNUC__ && 4 <= __GNUC__) || defined __clang__) && !defined __cplusplus + #define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b) + #endif + #include unsigned int s = sizeof (max_align_t); #if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__ int check1[2 * (__alignof__ (double) <= __alignof__ (max_align_t)) - 1];