Received: from eggs.gnu.org ([2001:4830:134:3::10]:38230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZylCb-0005Dr-Sn for qemu-devel@nongnu.org; Tue, 17 Nov 2015 13:42:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZylCX-0005Vy-Oq for qemu-devel@nongnu.org; Tue, 17 Nov 2015 13:42:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49806) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZylCX-0005Vr-K8 for qemu-devel@nongnu.org; Tue, 17 Nov 2015 13:41:57 -0500 From: Markus Armbruster References: <1447769349-1767-1-git-send-email-pbonzini@redhat.com> <874mgkh6f5.fsf@blackfin.pond.sub.org> <564B67BE.5040001@redhat.com> <564B702E.4070806@redhat.com> Date: Tue, 17 Nov 2015 19:41:54 +0100 In-Reply-To: (Peter Maydell's message of "Tue, 17 Nov 2015 18:24:58 +0000") Message-ID: <871tbobh8t.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2 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: Paolo Bonzini , Laszlo Ersek , QEMU Developers Peter Maydell writes: > On 17 November 2015 at 18:21, Paolo Bonzini wrote: >> >> >> On 17/11/2015 19:19, Peter Maydell wrote: >>> That doesn't seem like more than half-good news to me. In particular, >>> if ubsan is still diagnosing these cases and they're still a >>> problem in some constant expressions >> >> Constant expressions are standardese for e.g. >> >> static int x = 1 << 31; >> >> It doesn't mean _all_ constants, and the warning only triggers with >> -pedantic. > > But if "-fwrapv" means "this dialect of C makes shifts of > negative numbers well defined and OK" then "-1 << 31" > should be fine and should not provoke a warning (whether in > a constant expression or not). If that's not what -fwrapv means, > then we shouldn't be using it as if it did. A warning doesn't necessarily mean "this isn't well-defined". It could also mean "this might not be portable", or "we think your code is ugly". Inferring semantics from warnings is shaky business. Instead, let's ask the maintainers of gcc to clarify the meaning of -fwrapv.