sh: Remove undefined behaviour due to overflow in +/-/* in arithmetic.

With i386 base gcc and i386 base clang, arith_yacc.o remains unchanged.
This commit is contained in:
Jilles Tjoelker 2011-11-08 23:54:39 +00:00
parent 6376caed8e
commit 876f9b7800
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=227369

View File

@ -131,11 +131,11 @@ static arith_t do_binop(int op, arith_t a, arith_t b)
yyerror("divide error");
return op == ARITH_REM ? a % b : a / b;
case ARITH_MUL:
return a * b;
return (uintmax_t)a * (uintmax_t)b;
case ARITH_ADD:
return a + b;
return (uintmax_t)a + (uintmax_t)b;
case ARITH_SUB:
return a - b;
return (uintmax_t)a - (uintmax_t)b;
case ARITH_LSHIFT:
return a << b;
case ARITH_RSHIFT: