[RFA] handle value_binop BINOP_REM division by zero

Doug Evans dje@google.com
Wed Jan 30 16:53:00 GMT 2008


Unsigned division by zero got patched but not BINOP_REM.

Ok to check in?

2008-01-30  Doug Evans  <dje@google.com>

        * valarith.c (value_binop): Handle BINOP_REM division by zero.

Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.56
diff -u -p -r1.56 valarith.c
--- valarith.c  30 Jan 2008 07:28:16 -0000      1.56
+++ valarith.c  30 Jan 2008 16:40:26 -0000
@@ -1116,7 +1116,10 @@ value_binop (struct value *arg1, struct
              break;

            case BINOP_REM:
-             v = v1 % v2;
+             if (v2 !=0)
+               v = v1 % v2;
+             else
+               error (_("Division by zero"));
              break;

            case BINOP_MOD:



More information about the Gdb-patches mailing list