From 7338d820d45afffa841dced185116481d27bc76f Mon Sep 17 00:00:00 2001 From: qWord Date: Fri, 6 May 2016 18:32:43 +0200 Subject: [PATCH] Fix broken HIGHWORD-operator The HIGHWORD-Operator was implemented as right shift by 16 of opnd1->value. This is wrong because: - the bits 32...63 are not zeroed - the compiler might do an arithmetic shift (typeof opnd1->value == int_32) As fix, the result of the right shift is masked (bitwise AND) and then assigned to the 64 bit value opnd1->llvalue. Resolves: #152 resp. SF-BUG-298 --- expreval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/expreval.c b/expreval.c index a07986c..96ee26a 100644 --- a/expreval.c +++ b/expreval.c @@ -1488,7 +1488,7 @@ static ret_code highword_op( int oper, struct expr *opnd1, struct expr *opnd2, s //opnd1->mem_type = MT_WORD; /* v2.05 */ opnd1->mem_type = MT_EMPTY; } - opnd1->value = opnd1->value >> 16; + opnd1->llvalue = (opnd1->value >> 16) & 0xffff; return( NOT_ERROR ); }