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: Laszlo Ersek
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:36:29 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 11/17/15 11:26, Markus Armbruster wrote:
> 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

"wildly more", I think.

>> 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]