Skip to content

Commit

Permalink
target-i386: Don't left shift negative constant
Browse files Browse the repository at this point in the history
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 <ehabkost@redhat.com>
  • Loading branch information
ehabkost committed Oct 27, 2015
1 parent 7e038b9 commit 712b424
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion target-i386/translate.c
Expand Up @@ -2432,7 +2432,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));
if (!s->ss32)
tcg_gen_ext16u_tl(cpu_A0, cpu_A0);
tcg_gen_mov_tl(cpu_T[1], cpu_A0);
Expand Down

0 comments on commit 712b424

Please sign in to comment.