[PATCH] Silence misguided GCC warning about alignment issues
Johannes Schindelin
Johannes.Schindelin at gmx.de
Tue Aug 8 11:19:40 UTC 2017
Hi Emmanuel,
On Mon, 7 Aug 2017, Emmanuel Deloget wrote:
> And yes, its seems that the get_le32() macro in xz_private.h is a bit
> illegal with respect to strict aliasing, as it casts a uint8_t * into a
> const uint32_t *.
It would seem so.
Until you realize that it is used only on s->temp.buf (or `s->temp.buf + 4
* <number>`), and that the `buf` field was carefully placed after two
fields of type `size_t` (i.e. naturally aligned *at least* to a 32-bit
boundary).
If you are worried about that magic, you can even mark the `buf` field
using ALIGN4. But that *still* does not fix GCC's compiler warning. What
fixes it is my workaround of defining a static ALWAYS_INLINE function.
Denys' fix works around the problem, alright, but it also makes the code
slower. And it is *not* necessary to make the code slower.
Ciao,
Johannes
More information about the busybox
mailing list