From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zyf5x-00048e-TL for qemu-devel@nongnu.org; Tue, 17 Nov 2015 07:10:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zyf5s-0008DB-Ro for qemu-devel@nongnu.org; Tue, 17 Nov 2015 07:10:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34404) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zyf5s-0008D1-B9 for qemu-devel@nongnu.org; Tue, 17 Nov 2015 07:10:40 -0500 References: <1447754381-29882-1-git-send-email-pbonzini@redhat.com> <564B0150.7030400@redhat.com> <564B0386.4030701@redhat.com> <564B0817.1010704@redhat.com> From: Paolo Bonzini Message-ID: <564B193C.9070901@redhat.com> Date: Tue, 17 Nov 2015 13:10:36 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 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: Peter Maydell Cc: QEMU Developers On 17/11/2015 12:22, Peter Maydell wrote: > On 17 November 2015 at 10:57, Paolo Bonzini wrote= : >> >> >> On 17/11/2015 11:55, Peter Maydell wrote: >>> If you pass clang -fwrapv then this causes -fsanitize=3Dundefined 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 alrea= dy >> fixed -fwrapv once for pointers. >=20 > 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=3D255= 52 Paolo