qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH for 2.5] QEMU does not care about left shifts of signed negative values
Date: Tue, 17 Nov 2015 13:10:36 +0100	[thread overview]
Message-ID: <564B193C.9070901@redhat.com> (raw)
In-Reply-To: <CAFEAcA-P=yN55FNT5OEhwnW_SkfY5VzuA_3xsJB6+Qfz=R08NA@mail.gmail.com>



On 17/11/2015 12:22, Peter Maydell wrote:
> On 17 November 2015 at 10:57, Paolo Bonzini <pbonzini@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:
>  * 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)

Actually they document it under -fstrict-overflow ("Using '-fwrapv'
means that integer signed overflow is fully defined: it wraps") but it
would be nice to add it under -fwrapv as well.  I'll send a patch.

>  * clang need to document this
>  * -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

This + the ubsan issue is now https://llvm.org/bugs/show_bug.cgi?id=25552

Paolo

  reply	other threads:[~2015-11-17 12:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-17  9:59 [Qemu-devel] [PATCH for 2.5] QEMU does not care about left shifts of signed negative values Paolo Bonzini
2015-11-17 10:19 ` Peter Maydell
2015-11-17 10:28   ` Paolo Bonzini
2015-11-17 10:36     ` Peter Maydell
2015-11-17 10:37       ` Paolo Bonzini
2015-11-17 10:42         ` Peter Maydell
2015-11-17 10:55         ` Peter Maydell
2015-11-17 10:57           ` Paolo Bonzini
2015-11-17 11:22             ` Peter Maydell
2015-11-17 12:10               ` Paolo Bonzini [this message]
2015-11-17 12:22                 ` Peter Maydell
2015-11-17 10:41     ` Laszlo Ersek
2015-11-17 10:43       ` Paolo Bonzini
2015-11-17 10:52         ` Laszlo Ersek
2015-11-17 11:59       ` Markus Armbruster
2015-11-17 12:04         ` Peter Maydell
2015-11-17 12:17           ` Laszlo Ersek
2015-11-17 13:48           ` Paolo Bonzini
2015-11-17 12:18         ` Laszlo Ersek
2015-11-17 10:26 ` Markus Armbruster
2015-11-17 10:36   ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=564B193C.9070901@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).