qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] target-mips: Fix warning about shifting negativ


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] target-mips: Fix warning about shifting negative value
Date: Tue, 9 Aug 2016 09:24:02 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0


On 08/08/2016 15:56, Pranith Kumar wrote:
> Hi Paolo,
> 
> On Mon, Aug 8, 2016 at 5:11 AM, Paolo Bonzini <address@hidden> wrote:
>>
>>
>> On 07/08/2016 03:15, Pranith Kumar wrote:
>>> With latest clang you get the following warning:
>>>
>>> warning: shifting a negative signed value is undefined 
>>> [-Wshift-negative-value]
>>>
>>> Fix the warning by changing negative shift to inverse 0 shift.
>>>
>>
>> No, please no.
>>
>> clang is wrong in putting this under -Wall.
>>
> 
> Can you please explain why this warning is spurious? Isn't this what
> the standard says?

Yes, but GCC promises to never exploit this kind of undefined behavior.

Furthermore (though it's not the case for this patch) it's easy to get
this "fix" wrong.  For example if you change -1 << 3 to -1u << 3, and
then the value is extended to 64-bit, the results will be different.

Paolo



reply via email to

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