From fb2c34f8cdc59c0bffb0dec444c78c602afcaf6a Mon Sep 17 00:00:00 2001 From: bellard Date: Sat, 28 Oct 2006 14:47:39 +0000 Subject: [PATCH] fixed sign extension in some type conversions (Dave Dodge) --- tcc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tcc.c b/tcc.c index fdac44c..f6e3bab 100644 --- a/tcc.c +++ b/tcc.c @@ -5764,6 +5764,10 @@ void force_charshort_cast(int t) bits = 32 - bits; vpushi(bits); gen_op(TOK_SHL); + /* result must be signed or the SAR is converted to an SHL + This was not the case when "t" was a signed short + and the last value on the stack was an unsigned int */ + vtop->type.t &= ~VT_UNSIGNED; vpushi(bits); gen_op(TOK_SAR); }