Fix right shifts on arches with db_expr_t larger than u_int (LP64 arches

in practice).

db_expr_t is a signed type, but right shifts are fudged to evaluate
them in an unsigned type, and the unsigned type was broken by hard-
coding it as 'unsigned', so casting to it lost the top bits on arches
with db_expr_t larger than u_int.

The unsigned type with the same size as db_expr_t is not declared;
assume that db_addr_t gives it.  Fixing this properly is less important
than using the correct type for db_expr_t (originally always long for
C90, but always intmax_t since C99).
This commit is contained in:
bde 2017-03-18 07:01:18 +00:00
parent de11bb5bbe
commit 1134e42b34

View File

@ -261,7 +261,7 @@ db_shift_expr(db_expr_t *valuep)
lhs <<= rhs;
else {
/* Shift right is unsigned */
lhs = (unsigned) lhs >> rhs;
lhs = (db_addr_t)lhs >> rhs;
}
t = db_read_token();
}