On Sun, 23 Nov 2025, LIU Hao wrote:
在 2025-11-23 07:20, Martin Storsjö 写道:
This silences Clang warnings like this:
../math/fmal.c:34:3: warning: packed attribute is unnecessary for
'struct x87reg_::(anonymous at ../math/fmal.c:34:3)' [-Wpacked]
No attribute is needed for making these structs keep their
intended layout.
While Clang did warn about the other cases, it didn't warn about
the case in math/frexpl.c being unnecessary - but this one isn't
necessary either.
On x86-32 we have:
sizeof(double) = 8
alignof(double) = 8
sizeof(long double) = 12
alignof(long double) = 4
Because the struct has a `uint64_t` member, the `packed` attribute reduces
its alignment from 8 to 4, and removes 4 padding bytes. So it does alter the
layout for x86-32; it just doesn't alter the behavior.
The change looks good to me if it can pass the CI.
It does pass the CI - but I'm wondering if we should do this...
We probably should only do this about the cases that Clang actually warns
about; in this patch I also remove it in math/frexpl.c, but Clang didn't
comment on that one.
It also turns out that Clang actually differs from GCC about what it
thinks the size of the bitfield struct is, for the cases that it does
claim doesn't need the packed attribute - see
https://gcc.godbolt.org/z/soGraGc54.
It only affects the size of the struct though, so it shouldn't be a
problem in practice, and the CI is passing in either case though.
So with that in mind, I kinda feel we maybe shouldn't be touching this at
all. IMO it seems like -Wpacked is a kinda unnecessary warning here; it's
not enabled by default by either -Wall or -Wextra. So perhaps we just
should remove it from our configure.ac?
// Martin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public