On 2024-10-31 17:30, Bruno Haible wrote:
There is no harm, right.
OK, thanks, I patched Autoconf and propagated it into Gnulib as per
attached.From c7f29c827df9284ec56233c515286c4d57361e4c Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Thu, 31 Oct 2024 19:22:22 -0700
Subject: [PATCH] malloc, realloc: fix $3 bug
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2024-10/msg00284.html
* m4/malloc.m4 (_AC_FUNC_MALLOC_IF):
* m4/realloc.m4 (_AC_FUNC_REALLOC_IF):
Sync from bleeding-edge Autoconf again.
---
ChangeLog | 9 +++++++++
m4/malloc.m4 | 30 +++++++++++++-----------------
m4/realloc.m4 | 30 +++++++++++++-----------------
3 files changed, 35 insertions(+), 34 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index aa0b1a538f..fcf057ebfe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-10-31 Paul Eggert <egg...@cs.ucla.edu>
+
+ malloc, realloc: fix $3 bug
+ Problem reported by Bruno Haible in:
+ https://lists.gnu.org/r/bug-gnulib/2024-10/msg00284.html
+ * m4/malloc.m4 (_AC_FUNC_MALLOC_IF):
+ * m4/realloc.m4 (_AC_FUNC_REALLOC_IF):
+ Sync from bleeding-edge Autoconf again.
+
2024-10-31 Bruno Haible <br...@clisp.org>
crc: Support generating the tables also when cross-compiling.
diff --git a/m4/malloc.m4 b/m4/malloc.m4
index 06a8b7b5ed..0d4014de44 100644
--- a/m4/malloc.m4
+++ b/m4/malloc.m4
@@ -8,12 +8,12 @@ dnl This file is offered as-is, without any warranty.
m4_version_prereq([2.73], [], [
# This is copied from upstream Autoconf here:
-# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=74df3c673320c06481f5c5b18ff7979a3034a9e5#n971
-# _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT, UNKNOWN-ASSUME)
-# ----------------------------------------------------
+# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=f8c82d292699fbce6d60abb46259a3781578f7fc#n971
+# _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT[, UNKNOWN-ASSUME])
+# ------------------------------------------------------
# If 'malloc (0, 0)' returns nonnull, run IF-WORKS, otherwise, IF-NOT.
# If it is not known whether it works, assume the shell word UNKNOWN-ASSUME,
-# which should end in "yes" or in something else.
+# which should end in "yes" or in something else (the latter is the default).
AC_DEFUN([_AC_FUNC_MALLOC_IF],
[
AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
@@ -28,21 +28,17 @@ AC_DEFUN([_AC_FUNC_MALLOC_IF],
[[void *p = pmalloc (0);
int result = !p;
free (p);
- return result;]])
- ],
+ return result;]])],
[ac_cv_func_malloc_0_nonnull=yes],
[ac_cv_func_malloc_0_nonnull=no],
- [case "$host_os" in
- # Guess yes on platforms where we know the result.
- *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
- | gnu* | *-musl* | midipix* | midnightbsd* \
- | hpux* | solaris* | cygwin* | mingw* | windows* | msys* )
- ac_cv_func_malloc_0_nonnull="guessing yes" ;;
- # Guess as follows if we don't know.
- *) ac_cv_func_malloc_0_nonnull=m4_if([$3],[],["guessing no"],[$3]) ;;
- esac
- ])
- ])
+ [AS_CASE([$host_os],
+ [# Guess yes on platforms where we know the result.
+ *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
+ | gnu* | *-musl* | midipix* | midnightbsd* \
+ | hpux* | solaris* | cygwin* | mingw* | windows* | msys*],
+ [ac_cv_func_malloc_0_nonnull="guessing yes"],
+ [# Guess as follows if we don't know.
+ ac_cv_func_malloc_0_nonnull=m4_default([$3], ["guessing no"])])])])
AS_CASE([$ac_cv_func_malloc_0_nonnull], [*yes], [$1], [$2])
])# _AC_FUNC_MALLOC_IF
])
diff --git a/m4/realloc.m4 b/m4/realloc.m4
index 62aca6dd28..4f414b4817 100644
--- a/m4/realloc.m4
+++ b/m4/realloc.m4
@@ -20,12 +20,12 @@ AC_DEFUN([gl_FUNC_REALLOC_SANITIZED],
m4_version_prereq([2.73], [], [
# This is copied from upstream Autoconf here:
-# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=74df3c673320c06481f5c5b18ff7979a3034a9e5#n1487
-# _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT, UNKNOWN-ASSUME)
-# -----------------------------------------------------
+# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=f8c82d292699fbce6d60abb46259a3781578f7fc#n1483
+# _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT[, UNKNOWN-ASSUME])
+# -------------------------------------------------------
# If 'realloc (0, 0)' returns nonnull, run IF-WORKS, otherwise, IF-NOT.
# If it is not known whether it works, assume the shell word UNKNOWN-ASSUME,
-# which should end in "yes" or in something else.
+# which should end in "yes" or in something else (the latter is the default).
AC_DEFUN([_AC_FUNC_REALLOC_IF],
[
AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
@@ -40,21 +40,17 @@ AC_DEFUN([_AC_FUNC_REALLOC_IF],
[[void *p = prealloc (0, 0);
int result = !p;
free (p);
- return result;]])
- ],
+ return result;]])],
[ac_cv_func_realloc_0_nonnull=yes],
[ac_cv_func_realloc_0_nonnull=no],
- [case "$host_os" in
- # Guess yes on platforms where we know the result.
- *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
- | gnu* | *-musl* | midipix* | midnightbsd* \
- | hpux* | solaris* | cygwin* | mingw* | windows* | msys* )
- ac_cv_func_realloc_0_nonnull="guessing yes" ;;
- # Guess as follows if we don't know.
- *) ac_cv_func_realloc_0_nonnull=m4_if([$3],[],["guessing no"],[$3]) ;;
- esac
- ])
- ])
+ [AS_CASE([$host_os],
+ [# Guess yes on platforms where we know the result.
+ *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
+ | gnu* | *-musl* | midipix* | midnightbsd* \
+ | hpux* | solaris* | cygwin* | mingw* | windows* | msys*],
+ [ac_cv_func_realloc_0_nonnull="guessing yes"],
+ [# Guess as follows if we don't know.
+ ac_cv_func_realloc_0_nonnull=m4_default([$3], ["guessing no"])])])])
AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2])
])# _AC_FUNC_REALLOC_IF
])
--
2.43.0