Received: from eggs.gnu.org ([2001:4830:134:3::10]:47908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwFBl-0007Jg-Ou for qemu-devel@nongnu.org; Tue, 10 Nov 2015 15:06:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwFBi-0002BW-Ge for qemu-devel@nongnu.org; Tue, 10 Nov 2015 15:06:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44683) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwFBi-0002BP-BD for qemu-devel@nongnu.org; Tue, 10 Nov 2015 15:06:42 -0500 From: Markus Armbruster References: <1447171055-29567-1-git-send-email-stefanha@redhat.com> <1447171055-29567-4-git-send-email-stefanha@redhat.com> <56422A70.8040306@redhat.com> <87vb99lmae.fsf@blackfin.pond.sub.org> Date: Tue, 10 Nov 2015 21:06:38 +0100 In-Reply-To: (Steven Noonan's message of "Tue, 10 Nov 2015 11:51:58 -0800") Message-ID: <87io59k4a9.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 3/3] disas/arm: avoid clang shifting negative signed warning List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Steven Noonan Cc: Peter Maydell , Paolo Bonzini , Eduardo Habkost , Stefan Hajnoczi , QEMU Developers Steven Noonan writes: > On Tue, Nov 10, 2015 at 10:52 AM, Markus Armbruster wrote: >> Peter Maydell writes: >> >>> On 10 November 2015 at 17:33, Paolo Bonzini wrote: >>>> >>>> >>>> On 10/11/2015 16:57, Stefan Hajnoczi wrote: >>>>> clang 3.7.0 on x86_64 warns about the following: >>>>> >>>>> disas/arm.c:1782:17: warning: shifting a negative signed value is undefined [-Wshift-negative-value] >>>>> imm |= (-1 << 7); >>>>> ~~ ^ >>>>> >>>>> Note that this patch preserves the tab indent in this source file >>>>> because the surrounding code still uses tabs. >>>>> >>>>> Signed-off-by: Stefan Hajnoczi >>>> >>>> I would like to know a case where (except with ubsan) clang actually >>>> uses the optimization. >>>> >>>> If not, this is just error message theatre (which is not news for clang) >>>> and shouldn't have been part of -Wall. >>> >>> It could be they're attempting to warn us now about the possibility >>> that in a future version of clang they will start using this UB >>> to optimize with. >>> >>> http://stackoverflow.com/questions/22883790/left-shift-of-negative-values >>> reports that Intel's ICC will use this in dead-code-elimination >>> optimization. One day clang might do that too. >> >> Nice example of a compiler being gratuitously nasty. >> > > I don't read this warning as "clang will do crazy things with your > code eventually". Clang has always been very verbose when it comes to > undefined behavior, and I don't think that's really a bad thing to do. [...] Misunderstanding? Clang's warning is at worst annoying, but nowhere near nasty. ICC concluding that code executing a left shift of a negative value must be unreachable is gratuitously nasty.