summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdbsupport/print-utils.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/gdbsupport/print-utils.cc b/gdbsupport/print-utils.cc
index 73ff1afda3..7bbb6deea7 100644
--- a/gdbsupport/print-utils.cc
+++ b/gdbsupport/print-utils.cc
@@ -278,7 +278,11 @@ int_string (LONGEST val, int radix, int is_signed, int width,
case 10:
{
if (is_signed && val < 0)
- return decimal2str ("-", -val, width);
+ /* Cast to unsigned before negating, to prevent runtime error:
+ negation of -9223372036854775808 cannot be represented in type
+ 'long int'; cast to an unsigned type to negate this value to
+ itself. */
+ return decimal2str ("-", -(ULONGEST)val, width);
else
return decimal2str ("", val, width);
}