From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zpgxh-0004ux-77 for qemu-devel@nongnu.org; Fri, 23 Oct 2015 14:21:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zpgxd-0003cA-8P for qemu-devel@nongnu.org; Fri, 23 Oct 2015 14:21:09 -0400 Received: from mail-qk0-x234.google.com ([2607:f8b0:400d:c09::234]:36368) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zpgxd-0003c4-3A for qemu-devel@nongnu.org; Fri, 23 Oct 2015 14:21:05 -0400 Received: by qkca6 with SMTP id a6so85438252qkc.3 for ; Fri, 23 Oct 2015 11:21:04 -0700 (PDT) Sender: Richard Henderson References: <1443558863-26132-1-git-send-email-ehabkost@redhat.com> <1443558863-26132-3-git-send-email-ehabkost@redhat.com> <560C8DF8.7020700@twiddle.net> <20151001170636.GD1260@thinpad.lan.raisama.net> <20151023150718.GA3935@thinpad.lan.raisama.net> From: Richard Henderson Message-ID: <562A7A8B.1030807@twiddle.net> Date: Fri, 23 Oct 2015 08:20:59 -1000 MIME-Version: 1.0 In-Reply-To: <20151023150718.GA3935@thinpad.lan.raisama.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] target-i386: Don't left shift negative constant List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: Paolo Bonzini , qemu-devel@nongnu.org On 10/23/2015 05:07 AM, Eduardo Habkost wrote: > On Thu, Oct 01, 2015 at 02:06:36PM -0300, Eduardo Habkost wrote: >> On Thu, Oct 01, 2015 at 11:35:52AM +1000, Richard Henderson wrote: >>> On 09/30/2015 06:34 AM, Eduardo Habkost wrote: >>>> Left shift of negative values is undefined behavior. Detected by clang: >>>> qemu/target-i386/translate.c:2423:26: runtime error: >>>> left shift of negative value -8 >>>> >>>> This changes the code to reverse the sign after the left shift. >>>> >>>> Signed-off-by: Eduardo Habkost >>>> --- >>>> target-i386/translate.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/target-i386/translate.c b/target-i386/translate.c >>>> index 8b35de1..cc59b7e 100644 >>>> --- a/target-i386/translate.c >>>> +++ b/target-i386/translate.c >>>> @@ -2420,7 +2420,7 @@ static void gen_pusha(DisasContext *s) >>>> { >>>> int i; >>>> gen_op_movl_A0_reg(R_ESP); >>>> - gen_op_addl_A0_im(-8 << s->dflag); >>>> + gen_op_addl_A0_im(-(8 << s->dflag)); >>> >>> Better as -8U << s->d_flag? >> >> That's even more confusing to me. I wouldn't want to require other >> people to read the C specification to find out how many type conversions >> are happening in that statement. (Because I will have to do that, to >> find out what's the type of "-8U"). >> >> I would prefer an expression that doesn't involve any type conversion. >> But you are more familiar with that code, so it's up to you. > > Ping? I would really like to fix this warning to be able to enable > check-mode by default in QEMU 2.5. Are there objections to get this > patch included? > None. r~