summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-08-15 02:18:06 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-08-15 02:18:44 -0700
commit3548fd8a53869ce6b42c47f690660cb8eddb8aab (patch)
tree4da084bfab97e61c649abb3332254d0ea898188f /configure.ac
parent6cbf73b5f9f51b5e25b855bf9f521c1ef070dd4a (diff)
downloademacs-3548fd8a53869ce6b42c47f690660cb8eddb8aab.tar.gz
Debug out-of-range make_fixnum args
With --enable-checking, make_fixnum (N) now checks that N is in fixnum range. Suggested by Pip Cet in: https://lists.gnu.org/r/emacs-devel/2019-07/msg00548.html A new function make_ufixnum (N) is for the rare cases where N is intended to be unsigned and is in the range 0..INTMASK. * configure.ac (AC_C_TYPEOF): Add. (HAVE_STATEMENT_EXPRESSIONS): Resurrect this macro. * src/fns.c (Frandom, hashfn_eq, hashfn_equal, hashfn_user_defined): * src/profiler.c (hashfn_profiler): Use make_ufixnum rather than make_fixum, since the argument is an unsigned integer in the range 0..INTMASK rather than a signed integer in the range MOST_NEGATIVE_FIXNUM..MOST_POSITIVE_FIXNUM. Typically this is for hashes. * src/lisp.h (lisp_h_make_fixnum_wrap) [USE_LSB_TAG]: Rename from lisp_h_make_fixnum. (lisp_h_make_fixnum): Redefine in terms of lisp_h_make_fixnum_wrap. Check for fixnum overflow on compilers like GCC that have statement expressions and typeof. (FIXNUM_OVERFLOW_P): Move up. (make_fixnum): Check for fixnum overflow. (make_ufixnum): New function, which checks that the arg fits into 0..INTMASK range.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac13
1 files changed, 13 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index c093d8650da..1400fcb5bc7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5371,6 +5371,19 @@ if test "$emacs_cv_struct_alignment" = yes; then
structure to an N-byte boundary.])
fi
+AC_C_TYPEOF
+
+AC_CACHE_CHECK([for statement expressions],
+ [emacs_cv_statement_expressions],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([], [[return ({ int x = 5; x-x; });]])],
+ [emacs_cv_statement_expressions=yes],
+ [emacs_cv_statement_expressions=no])])
+if test "$emacs_cv_statement_expressions" = yes; then
+ AC_DEFINE([HAVE_STATEMENT_EXPRESSIONS], 1,
+ [Define to 1 if statement expressions work.])
+fi
+
if test "${GNU_MALLOC}" = "yes" ; then
AC_DEFINE(GNU_MALLOC, 1,
[Define to 1 if you want to use the GNU memory allocator.])