From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhhKY-0001Kh-11 for qemu-devel@nongnu.org; Thu, 01 Oct 2015 13:07:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhhKU-0004vq-0S for qemu-devel@nongnu.org; Thu, 01 Oct 2015 13:07:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40009) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhhKT-0004vK-Rz for qemu-devel@nongnu.org; Thu, 01 Oct 2015 13:07:37 -0400 References: <1443558863-26132-1-git-send-email-ehabkost@redhat.com> <1443558863-26132-2-git-send-email-ehabkost@redhat.com> <560BE355.60901@redhat.com> <560C44F4.6030200@twiddle.net> <560D3A8B.4020603@redhat.com> From: Laszlo Ersek Message-ID: <560D6857.1030501@redhat.com> Date: Thu, 1 Oct 2015 19:07:35 +0200 MIME-Version: 1.0 In-Reply-To: <560D3A8B.4020603@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/2] target-i386: Use 1UL for bit shift List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , Peter Maydell , Richard Henderson Cc: Eduardo Habkost , QEMU Developers On 10/01/15 15:52, Paolo Bonzini wrote: > > > On 01/10/2015 11:24, Peter Maydell wrote: >> On 30 September 2015 at 21:24, Richard Henderson wrote: >>> On 09/30/2015 11:27 PM, Paolo Bonzini wrote: >>>> ps: Ego ceterum censeo that these warnings are useless and uglify the >>>> code unnecessarily. But it looks like I'm in a minority so the patch is >>>> okay. >> >>> I totally agree. There are no ones-compliment machines anymore, and so the >>> whole point of that "undefined" in the C standard is moot. Let's all accept >>> that shifts of signed quantities do exactly what we expect. >> >> I'd rather not do that without a documented statement from both >> clang and gcc teams that they won't use this UB to do optimizations >> that might break programs relying on it. History suggests they >> will happily do so if it improves a benchmark at all. > > Well, this is pretty much the only ubsan issue that we stumble upon. > You can imagine how common that is in the wild and how good a move that > would be to rely on that undefined behavior. > > In addition, C89 didn't say at all what the result was for signed data > types, so technically we could compile QEMU with -std=gnu89 (the default > until GCC5) and call it a day. > > Really the C standard should make this implementation-defined. Obligatory link: http://blog.regehr.org/archives/1180 :) >>> Without looking, I don't suppose either compiler has a switch to disable >>> just the shift part of ubsan? >> >> Not without turning off other shift checks which we would want to >> retain (like shifts greater than the bitwidth), I think. > > I agree those are valuable. > > Paolo >