aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/testsuite/gdb.base/arithmet.exp2
-rw-r--r--gdb/valarith.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.base/arithmet.exp b/gdb/testsuite/gdb.base/arithmet.exp
index b6009a3..4905c2e 100644
--- a/gdb/testsuite/gdb.base/arithmet.exp
+++ b/gdb/testsuite/gdb.base/arithmet.exp
@@ -98,3 +98,5 @@ gdb_test "print x-(y+w)" "3"
gdb_test "print x/(y*w)" "0"
gdb_test "print x-(y/w)" "9"
gdb_test "print (x+y)*w" "42"
+
+gdb_test "p /x -(-0x7fffffffffffffff - 1)" " = 0x8000000000000000"
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 6210267..526cc02 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -1382,7 +1382,10 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
break;
case BINOP_SUB:
- v = v1 - v2;
+ /* Avoid runtime error: signed integer overflow: \
+ 0 - -9223372036854775808 cannot be represented in type
+ 'long int'. */
+ v = (ULONGEST)v1 - (ULONGEST)v2;
break;
case BINOP_MUL: