emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 6039acb: Remove unneeded overflow check in integer division


From: Paul Eggert
Subject: master 6039acb: Remove unneeded overflow check in integer division
Date: Wed, 6 Nov 2019 01:55:57 -0500 (EST)

branch: master
commit 6039acb86113e21409dafe5ebf75d04fbe4577f6
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Remove unneeded overflow check in integer division
    
    * src/data.c (arith_driver): Remove unnecessary runtime test,
    since integer overflow is impossible on division of fixnums,
    given that the worst case is MOST_NEGATIVE_FIXNUM / -1 which is
    representable as an EMACS_INT (albeit not as a fixnum).
---
 src/data.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/data.c b/src/data.c
index d968ac9..955e507 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2944,7 +2944,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, 
Lisp_Object *args,
        /* Set ACCUM to the next operation's result if it fits,
           else exit the loop.  */
        bool overflow = false;
-       intmax_t a UNINIT;
+       intmax_t a;
        switch (code)
          {
          case Aadd : overflow = INT_ADD_WRAPV (accum, next, &a); break;
@@ -2953,9 +2953,8 @@ arith_driver (enum arithop code, ptrdiff_t nargs, 
Lisp_Object *args,
          case Adiv:
            if (next == 0)
              xsignal0 (Qarith_error);
-           overflow = INT_DIVIDE_OVERFLOW (accum, next);
-           if (!overflow)
-             a = accum / next;
+           eassert (! INT_DIVIDE_OVERFLOW (accum, next));
+           a = accum / next;
            break;
          case Alogand: accum &= next; continue;
          case Alogior: accum |= next; continue;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]