[PATCH] Silence misguided GCC warning about alignment issues
Emmanuel Deloget
logout at free.fr
Mon Aug 7 13:17:27 UTC 2017
Hello,
On Mon, Aug 7, 2017 at 12:25 PM, Lauri Kasanen <cand at gmx.com> wrote:
> On Mon, 7 Aug 2017 12:09:45 +0200 (CEST)
> Johannes Schindelin <johannes.schindelin at gmx.de> wrote:
>> Meaning: GCC gets this all wrong and should not complain. So let's force
>> it to be quiet for a couple of lines.
>
> I believe this is both wrong and dangerous. If gcc warns about it, it
> will also very likely try to mis-optimize the same case.
>
> - Lauri
I tried to carefully read the code, and I don't see where the aliasing
issue migh be.
* buf is an uin8_t []
* the code either use it as is, or promote it to const uint8_t *, or
cast it to (const) char *.
All of these types are compatible w.r.t. aliasing (and the C99
standard). I may have missed something though and my eyes might be
rusted.
Now, it seems that some might have seen a regression in GCC with
respect to aliasing rules [1][2]. This might be an instance of the bug
(according to the bug report, it's no longer reproducible in GCC
trunk).
Anyway, it might be a good idea to avoid unsetting the warning for one
buggy GCC version :)
Best regards,
-- Emmanuel Deloget
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80633
More information about the busybox
mailing list