Received: from eggs.gnu.org ([2001:4830:134:3::10]:52396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZydSi-0006tC-5D for qemu-devel@nongnu.org; Tue, 17 Nov 2015 05:26:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZydSe-0007Oe-5r for qemu-devel@nongnu.org; Tue, 17 Nov 2015 05:26:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60494) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZydSd-0007Oa-ST for qemu-devel@nongnu.org; Tue, 17 Nov 2015 05:26:04 -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 961C78E6E3 for ; Tue, 17 Nov 2015 10:26:03 +0000 (UTC) From: Markus Armbruster References: <1447754381-29882-1-git-send-email-pbonzini@redhat.com> Date: Tue, 17 Nov 2015 11:26:01 +0100 In-Reply-To: <1447754381-29882-1-git-send-email-pbonzini@redhat.com> (Paolo Bonzini's message of "Tue, 17 Nov 2015 10:59:41 +0100") Message-ID: <878u5wzzuu.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain 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: Paolo Bonzini Cc: qemu-devel@nongnu.org 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 > 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