2004-06-27 <david@streamline-computing.com>
authorDavid Lecomber <david@lecomber.net>
Sun, 27 Jun 2004 07:57:15 +0000 (07:57 +0000)
committerDavid Lecomber <david@lecomber.net>
Sun, 27 Jun 2004 07:57:15 +0000 (07:57 +0000)
Partial fix for PR cli/1056.
* valarith.c (value_binop): Check for zero in division and
remainder evaluation.

gdb/ChangeLog
gdb/valarith.c

index 989cf2c1c38bb1591f81d79208c5dd091a9c7296..5b86c074374d27cd9e6a1c1cf31f7b9727027e2d 100644 (file)
@@ -1,3 +1,9 @@
+2004-06-27    <david@streamline-computing.com>
+
+       Partial fix for PR cli/1056.
+       * valarith.c: Check for zero in division and remainder 
+       evaluation.
+
 2004-06-27  Mark Kettenis  <kettenis@gnu.org>
 
        * i387-tdep.c: Remove excessive whitespace.
index 1a86e921f42628a79e42583735a11e63f7f757a2..7858f91d0de2ac0e46f35610292c262a9a92cf24 100644 (file)
@@ -1040,7 +1040,10 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
              break;
 
            case BINOP_DIV:
-             v = v1 / v2;
+             if (v2 != 0)
+               v = v1 / v2;
+             else
+               error ("Division by zero");
               break;
 
             case BINOP_EXP:
@@ -1050,7 +1053,10 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
              break;
 
            case BINOP_REM:
-             v = v1 % v2;
+             if (v2 != 0)
+               v = v1 % v2;
+             else
+               error ("Division by zero");
              break;
 
            case BINOP_MOD: