From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyjiX-0007H0-Vg for qemu-devel@nongnu.org; Tue, 17 Nov 2015 12:06:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZyjiT-0004XJ-5g for qemu-devel@nongnu.org; Tue, 17 Nov 2015 12:06:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyjiT-0004Wu-1W for qemu-devel@nongnu.org; Tue, 17 Nov 2015 12:06:49 -0500 References: <1447769349-1767-1-git-send-email-pbonzini@redhat.com> <564B3E19.50804@redhat.com> <87y4dwljam.fsf@blackfin.pond.sub.org> <564B5BB0.2090202@redhat.com> From: Paolo Bonzini Message-ID: <564B5EA3.1090508@redhat.com> Date: Tue, 17 Nov 2015 18:06:43 +0100 MIME-Version: 1.0 In-Reply-To: <564B5BB0.2090202@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 for 2.5] QEMU does not care about left shifts of signed negative values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laszlo Ersek , Markus Armbruster Cc: Peter Maydell , qemu-devel@nongnu.org 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