From 6039acb86113e21409dafe5ebf75d04fbe4577f6 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 5 Nov 2019 22:55:23 -0800 Subject: [PATCH] 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 d968ac9e3a9..955e5073900 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; -- 2.39.5