[PATCH] Silence misguided GCC warning about alignment issues

Denys Vlasenko vda.linux at googlemail.com
Mon Aug 7 18:53:54 UTC 2017


On Mon, Aug 7, 2017 at 12:09 PM, Johannes Schindelin
<johannes.schindelin at gmx.de> wrote:
> When compiling xz_dec_stream.c with GCC 7.1.0, it complains thusly:
>
>         In function 'dec_stream_footer':
>         error: dereferencing type-punned pointer will break strict-aliasing
>               rules [-Werror=strict-aliasing]
>            if (xz_crc32(s->temp.buf + 4, 6, 0) != get_le32(s->temp.buf))
>                ^~
>
> The thing is, the `buf` field was put just after two fields of type
> size_t for the express purpose of avoiding alignment issues, as per the
> comment above the `temp` struct.
>
> Meaning: GCC gets this all wrong and should not complain. So let's force
> it to be quiet for a couple of lines.

xz_crc32 is:

xz_crc32(const uint8_t *buf, size_t size, uint32_t crc)

I think gcc is not complaining about xz_crc32,
it complains about get_le32!

Can you test this theory by splitting that statement in two?


More information about the busybox mailing list