From: Paolo Bonzini <pbonzini@redhat.com>
To: Laszlo Ersek <lersek@redhat.com>, Markus Armbruster <armbru@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 for 2.5] QEMU does not care about left shifts of signed negative values
Date: Tue, 17 Nov 2015 18:06:43 +0100 [thread overview]
Message-ID: <564B5EA3.1090508@redhat.com> (raw)
In-Reply-To: <564B5BB0.2090202@redhat.com>
On 17/11/2015 17:54, Laszlo Ersek wrote:
> I'm not worried. I hate it for the mental load it represents.
>
> For me, the fact that the negative sign is encoded (with *any* kind of
> representation) within the bit pattern subject to shifting, makes the
> negative sign *inherently* incompatible with shifting.
>
> In real life, *you don't shift a sign*. It just makes no sense. The sign
> is not a digit. You can append or cut off zeroes from the right, but the
> sign is not subject to that. The sign doesn't care.
I agree. That's why I said elsewhere that it's *okay* for me if e.g.
0xC0000000u << 2 is undefined behavior. In fact, it's mostly okay for
me if shift _into_ the sign bit were undefined behavior.
Basically, I avoid the "mental load" with a rule that left shift is just
multiplication by 2^N.
Paolo
next prev parent reply other threads:[~2015-11-17 17:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-17 14:09 [Qemu-devel] [PATCH v2 for 2.5] QEMU does not care about left shifts of signed negative values Paolo Bonzini
2015-11-17 14:47 ` Laszlo Ersek
2015-11-17 15:47 ` Markus Armbruster
2015-11-17 16:54 ` Laszlo Ersek
2015-11-17 17:06 ` Paolo Bonzini [this message]
2015-11-17 18:22 ` Markus Armbruster
2015-11-17 17:39 ` Markus Armbruster
2015-11-17 17:45 ` Paolo Bonzini
2015-11-17 18:19 ` Peter Maydell
2015-11-17 18:21 ` Paolo Bonzini
2015-11-17 18:24 ` Peter Maydell
2015-11-17 18:36 ` Paolo Bonzini
2015-11-17 18:40 ` Peter Maydell
2015-11-17 18:41 ` Markus Armbruster
2015-11-17 19:54 ` Paolo Bonzini
2015-11-17 18:24 ` Markus Armbruster
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=564B5EA3.1090508@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=lersek@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).