[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
alignasof, stdalign: Fix a compilation error on FreeBSD 12.0
From: |
Bruno Haible |
Subject: |
alignasof, stdalign: Fix a compilation error on FreeBSD 12.0 |
Date: |
Tue, 24 Jan 2023 14:02:34 +0100 |
On FreeBSD 12.0/i386 I get a compilation error when building a testdir
for module 'rawmemchr'.
On the master branch, the first error is:
In file included from ../../gllib/rawmemchr.c:17:
In file included from ../config.h:1018:
In file included from /usr/include/stddef.h:41:
/usr/include/sys/_types.h:106:35: error: expected expression
long long __max_align1 __aligned(_Alignof(long long));
^
../config.h:964:39: note: expanded from macro '_Alignof'
# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
^
On the stable-202301 branch, the first error is:
In file included from ../../gllib/rawmemchr.c:17:
In file included from ../config.h:925:
In file included from ./stdalign.h:131:
In file included from /usr/include/stddef.h:41:
/usr/include/sys/_types.h:106:35: error: expected expression
long long __max_align1 __aligned(_Alignof(long long));
^
./stdalign.h:70:36: note: expanded from macro '_Alignof'
# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
^
What happens is that
- config.h includes <stdalign.h>, per the patch that I submitted in
<https://lists.gnu.org/archive/html/bug-gnulib/2022-09/msg00144.html>.
- This <stdalign.h> is the gnulib-generated one.
(In <https://lists.gnu.org/archive/html/bug-gnulib/2022-09/msg00144.html>
the purpose of my patch was to avoid including the gnulib-generated
stdalign.h, but it did not achieve that goal since on this platform
HAVE_STDALIGN_H is 1, following these configure findings:
checking for stdalign.h... yes
checking for alignas and alignof... no
. Anyway.)
- At the end of <stdalign.h>, <stddef.h> gets included.
- <stddef.h> includes <sys/_types.h>, which attempts to define max_align_t.
For this it uses _Alignof(long long), which expands to
offsetof (struct { char __a; long long __b; }, __b)
- But at this point offsetof is not yet defined (since <stddef.h> is still
being included).
The following patch fixes it. One in master, a different one for the
stable-202301 branch. (On the stable-202207 branch there is no problem.)
0001-master-alignasof-stdalign-Fix-a-compilation-error-on-FreeBS.patch
Description: Text Data
0001-stable-stdalign-Fix-a-compilation-error-on-FreeBSD-12.0.patch
Description: Text Data
- alignasof, stdalign: Fix a compilation error on FreeBSD 12.0,
Bruno Haible <=