• Paul Eggert's avatar
    Debug out-of-range make_fixnum args · 3548fd8a
    Paul Eggert authored
    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.
    3548fd8a
configure.ac 195 KB