On 17 November 2015 at 10:57, Paolo Bonzini <pbonz...@redhat.com> wrote:
>
>
> On 17/11/2015 11:55, Peter Maydell wrote:
>> If you pass clang -fwrapv then this causes -fsanitize=undefined to
>> no longer complain about signed integer overflows from addition.
>> However the sanitizer will still complain about left shifts of
>> negative values. The conclusion I draw is that clang (as per
>> the documentation) applies fwrapv only to addition &c, not to
>> shifts.
>
> Ok, I'll open a bug for this.  It's probably unintended, they've already
> fixed -fwrapv once for pointers.

Thanks. Other things that would need to be fixed for -fwrapv to
apply to shifts:
 * clang need to document this
 * gcc need to document this (this is a stronger statement than
   what they currently have since it is a guarantee not to change
   the semantics in the future if -fwrapv is set)
 * -fwrapv in clang should suppress -Wshift-negative-value
 * ideally, test cases in both the clang and gcc test suites to
   defend the 2s-complement signed shift semantics

thanks
-- PMM

Reply via email to