From c230dfdc26f0ffffd0718120d5e49478ae7cbb72 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 20 Nov 2025 11:59:47 -0800 Subject: [PATCH] A few more functions are not pure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assuming ATTRIBUTE_PURE means that the function must return, a few more functions that should not be declared with ATTRIBUTE_PURE. The GCC manual (and even the C23 standard, with [[reproducible]]) is not clear about this, and it’s better to be safe. * src/bignum.h (mpz_get_d_rounded): * src/lisp.h (bignum_to_double): No longer pure, as it does not return if memory is exhausted. * src/fns.c (Fproper_list_p): No longer pure, as it does not return if the user quits. * src/gnutls.c (Fgnutls_errorp): No longer pure, as it does not return if it runs into an eassert failure in XSYMBOL_WITH_POS via EQ. * src/lisp.h (bignum_to_intmax, bignum_to_uintmax, bignum_bufsize): No longer pure, as it does not return if it runs into an eassert failure in XBIGNUM via xbignum_val. --- src/bignum.h | 2 +- src/fns.c | 3 +-- src/gnutls.c | 3 +-- src/lisp.h | 10 +++++----- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/bignum.h b/src/bignum.h index 132fa31f0f5..9be3a41fd35 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -56,7 +56,7 @@ extern void emacs_mpz_mul_2exp (mpz_t, mpz_t const, EMACS_INT) ARG_NONNULL ((1, 2)); extern void emacs_mpz_pow_ui (mpz_t, mpz_t const, unsigned long) ARG_NONNULL ((1, 2)); -extern double mpz_get_d_rounded (mpz_t const) ATTRIBUTE_PURE; +extern double mpz_get_d_rounded (mpz_t const); extern Lisp_Object get_random_bignum (struct Lisp_Bignum const *); INLINE_HEADER_BEGIN diff --git a/src/fns.c b/src/fns.c index 7d3c941a936..157022a5c44 100644 --- a/src/fns.c +++ b/src/fns.c @@ -242,8 +242,7 @@ counted. */) DEFUN ("proper-list-p", Fproper_list_p, Sproper_list_p, 1, 1, 0, doc: /* Return OBJECT's length if it is a proper list, nil otherwise. -A proper list is neither circular nor dotted (i.e., its last cdr is nil). */ - attributes: pure) +A proper list is neither circular nor dotted (i.e., its last cdr is nil). */) (Lisp_Object object) { ptrdiff_t len = 0; diff --git a/src/gnutls.c b/src/gnutls.c index 247cc7ff3fe..31827280b48 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -1002,8 +1002,7 @@ See also `gnutls-boot'. */) DEFUN ("gnutls-errorp", Fgnutls_errorp, Sgnutls_errorp, 1, 1, 0, doc: /* Return t if ERROR indicates a GnuTLS problem. ERROR is an integer or a symbol with an integer `gnutls-code' property. -usage: (gnutls-errorp ERROR) */ - attributes: pure) +usage: (gnutls-errorp ERROR) */) (Lisp_Object err) { if (EQ (err, Qt) diff --git a/src/lisp.h b/src/lisp.h index fe8e2aaea72..0d457345d85 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -619,13 +619,13 @@ INLINE void set_sub_char_table_contents (Lisp_Object, ptrdiff_t, /* Defined in bignum.c. */ extern int check_int_nonnegative (Lisp_Object); extern intmax_t check_integer_range (Lisp_Object, intmax_t, intmax_t); -extern double bignum_to_double (Lisp_Object) ATTRIBUTE_PURE; +extern double bignum_to_double (Lisp_Object); extern Lisp_Object make_bigint (intmax_t); extern Lisp_Object make_biguint (uintmax_t); extern uintmax_t check_uinteger_max (Lisp_Object, uintmax_t); /* Defined in chartab.c. */ -extern Lisp_Object char_table_ref (Lisp_Object, int) ATTRIBUTE_PURE; +extern Lisp_Object char_table_ref (Lisp_Object, int); extern void char_table_set (Lisp_Object, int, Lisp_Object); /* Defined in data.c. */ @@ -4105,9 +4105,9 @@ set_sub_char_table_contents (Lisp_Object table, ptrdiff_t idx, Lisp_Object val) /* Defined in bignum.c. This part of bignum.c's API does not require the caller to access bignum internals; see bignum.h for that. */ -extern intmax_t bignum_to_intmax (Lisp_Object) ATTRIBUTE_PURE; -extern uintmax_t bignum_to_uintmax (Lisp_Object) ATTRIBUTE_PURE; -extern ptrdiff_t bignum_bufsize (Lisp_Object, int) ATTRIBUTE_PURE; +extern intmax_t bignum_to_intmax (Lisp_Object); +extern uintmax_t bignum_to_uintmax (Lisp_Object); +extern ptrdiff_t bignum_bufsize (Lisp_Object, int); extern ptrdiff_t bignum_to_c_string (char *, ptrdiff_t, Lisp_Object, int); extern Lisp_Object bignum_to_string (Lisp_Object, int); extern Lisp_Object make_bignum_str (char const *, int);