[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [PATCH] Remove left shifts of negative signed integer
From: |
John Snow |
Subject: |
Re: [Qemu-trivial] [PATCH] Remove left shifts of negative signed integers |
Date: |
Thu, 30 Jun 2016 16:20:39 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 |
On 06/30/2016 04:15 PM, Paolo Bonzini wrote:
>
>
> ----- Original Message -----
>> From: "John Snow" <address@hidden>
>> To: address@hidden
>> Cc: address@hidden, address@hidden, address@hidden, "peter maydell"
>> <address@hidden>,
>> "John Snow" <address@hidden>
>> Sent: Thursday, June 30, 2016 9:36:36 PM
>> Subject: [PATCH] Remove left shifts of negative signed integers
>>
>> Another exercise in placating Clang's increasingly strict -Werror mode.
>> Technically, this is undefined behavior. In practice, -N<<M is the same
>> as -(N<<M).
>>
>> Signed-off-by: John Snow <address@hidden>
>
> There's been discussions on this in the past; sorry but this is a
> super-duper NACK.
>
> GCC correctly puts this warning under -Wextra, and promises not to ever
> make use of this facet of undefined behavior. The only correct patch
> is the one that disables the warning for clang, and possibly adds
> -fwrapv. In GCC, -fwrapv correctly silences ubsan's left-shift
> and signed-overflow warnings. In Clang, this is reported at
> https://llvm.org/bugs/show_bug.cgi?id=25552. It's a heavy hammer
> but it's the safest options as compiler evolve.
>
> Paolo
>
Where /exactly/ do you propose we canonicalize the clang invocation you
would like to support?
--js