qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/2] target-i386: Don't left shift negative cons


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH 2/2] target-i386: Don't left shift negative constant
Date: Thu, 1 Oct 2015 11:35:52 +1000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

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 <address@hidden>
---
  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?



      if (!s->ss32)
          tcg_gen_ext16u_tl(cpu_A0, cpu_A0);
      tcg_gen_mov_tl(cpu_T[1], cpu_A0);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]