qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for 2.5] QEMU does not care about left shifts of


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH for 2.5] QEMU does not care about left shifts of signed negative values
Date: Tue, 17 Nov 2015 11:26:01 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Paolo Bonzini <address@hidden> 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 <address@hidden>

Reviewed-by: Markus Armbruster <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]