From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zydcp-0000Xp-Fw for qemu-devel@nongnu.org; Tue, 17 Nov 2015 05:36:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zydcm-0001d0-7P for qemu-devel@nongnu.org; Tue, 17 Nov 2015 05:36:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zydcm-0001cs-1y for qemu-devel@nongnu.org; Tue, 17 Nov 2015 05:36:32 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 5635AC076600 for ; Tue, 17 Nov 2015 10:36:31 +0000 (UTC) References: <1447754381-29882-1-git-send-email-pbonzini@redhat.com> <878u5wzzuu.fsf@blackfin.pond.sub.org> From: Laszlo Ersek Message-ID: <564B032D.1030103@redhat.com> Date: Tue, 17 Nov 2015 11:36:29 +0100 MIME-Version: 1.0 In-Reply-To: <878u5wzzuu.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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: Markus Armbruster , Paolo Bonzini Cc: qemu-devel@nongnu.org On 11/17/15 11:26, Markus Armbruster wrote: > Paolo Bonzini writes: > >> There's no reason for the compiler to exploit the undefinedness of left >> shifts, In fact GCC explicitly documents that they do not use at all >> all this possibility. They also say this is subject to change, but > > Suggest to scratch one of two "all" :) > >> they have been saying this for 10 years (since the wording appeared in >> the GCC 4.0 manual). >> >> Any workaround for this particular case of undefined behavior uglifies >> the code: using unsigned is unsafe because the value becomes positive >> when extended; using -(a << b) does not express as well that the >> intention is to compute -a * 2^N. >> >> Clang has just added an obnoxious, pointless, *totally useless*, unsafe >> warning about this. It's obnoxious and pointless because the compiler >> is not using the latitude that the standard gives it, so it just adds >> noise. It is useless and unsafe because it does not catch the widely >> more common case where the LHS is a variable, and thus gives a false "wildly more", I think. >> sense of security. >> >> The noisy nature of the warning means that it should have never been >> added to -Wall. The uselessness means that it probably should not >> have even been added to -Wextra. >> >> Document this explicitly, and shut up the stupid warning. >> >> >> Signed-off-by: Paolo Bonzini > > Reviewed-by: Markus Armbruster >