Paolo Bonzini <pbonz...@redhat.com> writes:

> There's no reason for the compiler to exploit the undefinedness of left
> shifts, In fact GCC explicitly documents that they do not use at all
> all this possibility.  They also say this is subject to change, but

Suggest to scratch one of two "all" :)

> they have been saying this for 10 years (since the wording appeared in
> the GCC 4.0 manual).
>
> Any workaround for this particular case of undefined behavior uglifies
> the code: using unsigned is unsafe because the value becomes positive
> when extended; using -(a << b) does not express as well that the
> intention is to compute -a * 2^N.
>
> Clang has just added an obnoxious, pointless, *totally useless*, unsafe
> warning about this.  It's obnoxious and pointless because the compiler
> is not using the latitude that the standard gives it, so it just adds
> noise.  It is useless and unsafe because it does not catch the widely
> more common case where the LHS is a variable, and thus gives a false
> sense of security.
>
> The noisy nature of the warning means that it should have never been
> added to -Wall.  The uselessness means that it probably should not
> have even been added to -Wextra.
>
> Document this explicitly, and shut up the stupid warning.
> </rant>
>
> Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>

Reviewed-by: Markus Armbruster <arm...@redhat.com>

Reply via email to