aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorPaul Eggert2018-08-17 00:25:20 -0700
committerPaul Eggert2018-08-17 00:26:19 -0700
commit64eb9b71da7c3c34541929c1b0dfb7f0c11d3d88 (patch)
tree0b905edf417cb3e62706d84e5776a2a26065453f /src/data.c
parent3b9017b5ba6b7041fbf70691092533286cc9b98d (diff)
downloademacs-64eb9b71da7c3c34541929c1b0dfb7f0c11d3d88.tar.gz
emacs-64eb9b71da7c3c34541929c1b0dfb7f0c11d3d88.zip
Fix problems with logxor etc. and fixnums
These operations incorrectly treated negative fixnums as bignums greater than most-positive-fixnum. * src/alloc.c (mpz_set_intmax_slow): Avoid undefined behavior if signed unary negation overflows, while we’re in the neighborhood. (mpz_set_uintmax_slow): Remove. All uses removed. * src/data.c (arith_driver): Treat fixnums as signed, not unsigned, even for logical operations. * src/lisp.h (mpz_set_uintmax): Remove. All uses removed. * test/src/data-tests.el (data-tests-logand) (data-tests-logior, data-tests-logxor): New tests.
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/data.c b/src/data.c
index 66f508c8f43..5a355d9787c 100644
--- a/src/data.c
+++ b/src/data.c
@@ -3006,7 +3006,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args)
3006 { 3006 {
3007 mpz_t tem; 3007 mpz_t tem;
3008 mpz_init (tem); 3008 mpz_init (tem);
3009 mpz_set_uintmax (tem, XUFIXNUM (val)); 3009 mpz_set_intmax (tem, XFIXNUM (val));
3010 mpz_and (accum, accum, tem); 3010 mpz_and (accum, accum, tem);
3011 mpz_clear (tem); 3011 mpz_clear (tem);
3012 } 3012 }
@@ -3018,7 +3018,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args)
3018 { 3018 {
3019 mpz_t tem; 3019 mpz_t tem;
3020 mpz_init (tem); 3020 mpz_init (tem);
3021 mpz_set_uintmax (tem, XUFIXNUM (val)); 3021 mpz_set_intmax (tem, XFIXNUM (val));
3022 mpz_ior (accum, accum, tem); 3022 mpz_ior (accum, accum, tem);
3023 mpz_clear (tem); 3023 mpz_clear (tem);
3024 } 3024 }
@@ -3030,7 +3030,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args)
3030 { 3030 {
3031 mpz_t tem; 3031 mpz_t tem;
3032 mpz_init (tem); 3032 mpz_init (tem);
3033 mpz_set_uintmax (tem, XUFIXNUM (val)); 3033 mpz_set_intmax (tem, XFIXNUM (val));
3034 mpz_xor (accum, accum, tem); 3034 mpz_xor (accum, accum, tem);
3035 mpz_clear (tem); 3035 mpz_clear (tem);
3036 } 3036 }