summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-05-23 22:13:45 +0200
committerBruno Haible <bruno@clisp.org>2020-05-23 22:13:45 +0200
commit3d29ad5500aca06b0f56bbe979b09c32017f6c1d (patch)
treecf018239f455fbbaffd05f7cadbc6e94cd36cffa
parent665e4118cbfc611e1e9b1767f0817a5903e29e8b (diff)
downloadgnulib-3d29ad5500aca06b0f56bbe979b09c32017f6c1d.tar.gz
gnulib-3d29ad5500aca06b0f56bbe979b09c32017f6c1d.tar.bz2
calloc-gnu: Avoid wrong configure results with GCC's AddressSanitizer.
* m4/calloc.m4 (_AC_FUNC_CALLOC_IF): Split the AC_RUN_IFELSE into two AC_RUN_IFELSE invocations.
-rw-r--r--ChangeLog6
-rw-r--r--m4/calloc.m471
2 files changed, 49 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 3d4c0f8b0d..004f069c3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2020-05-23 Bruno Haible <bruno@clisp.org>
+ calloc-gnu: Avoid wrong configure results with GCC's AddressSanitizer.
+ * m4/calloc.m4 (_AC_FUNC_CALLOC_IF): Split the AC_RUN_IFELSE into two
+ AC_RUN_IFELSE invocations.
+
+2020-05-23 Bruno Haible <bruno@clisp.org>
+
isnanf, isnanl, isnan: Don't use nonexistent builtins with clang.
* m4/isnanf.m4 (gl_HAVE_ISNANF_NO_LIBM, gl_HAVE_ISNANF_IN_LIBM,
gl_ISNANF_WORKS): Don't use __builtin_isnanf on clang versions that
diff --git a/m4/calloc.m4 b/m4/calloc.m4
index 3361cba7a6..a93439e8c8 100644
--- a/m4/calloc.m4
+++ b/m4/calloc.m4
@@ -1,4 +1,4 @@
-# calloc.m4 serial 21
+# calloc.m4 serial 22
# Copyright (C) 2004-2020 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
@@ -21,33 +21,48 @@ AC_DEFUN([_AC_FUNC_CALLOC_IF],
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_CACHE_CHECK([for GNU libc compatible calloc],
[ac_cv_func_calloc_0_nonnull],
- [AC_RUN_IFELSE(
- [AC_LANG_PROGRAM(
- [AC_INCLUDES_DEFAULT],
- [[int result = 0;
- char * volatile p = calloc (0, 0);
- if (!p)
- result |= 1;
- free (p);
- p = calloc ((size_t) -1 / 8 + 1, 8);
- if (p)
- result |= 2;
- free (p);
- return result;
- ]])],
- [ac_cv_func_calloc_0_nonnull=yes],
- [ac_cv_func_calloc_0_nonnull=no],
- [case "$host_os" in
- # Guess yes on glibc systems.
- *-gnu* | gnu*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
- # Guess yes on musl systems.
- *-musl*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
- # Guess yes on native Windows.
- mingw*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
- # If we don't know, obey --enable-cross-guesses.
- *) ac_cv_func_calloc_0_nonnull="$gl_cross_guess_normal" ;;
- esac
- ])])
+ [if test $cross_compiling != yes; then
+ ac_cv_func_calloc_0_nonnull=yes
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [AC_INCLUDES_DEFAULT],
+ [[int result = 0;
+ char * volatile p = calloc (0, 0);
+ if (!p)
+ result |= 1;
+ free (p);
+ return result;
+ ]])],
+ [],
+ [ac_cv_func_calloc_0_nonnull=no])
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [AC_INCLUDES_DEFAULT],
+ [[int result = 0;
+ char * volatile p = calloc ((size_t) -1 / 8 + 1, 8);
+ if (!p)
+ result |= 2;
+ free (p);
+ return result;
+ ]])],
+ dnl The exit code of this program is 0 if calloc() succeeded (which
+ dnl it shouldn't), 2 if calloc() failed, or 1 if some leak sanitizer
+ dnl terminated the program as a result of the calloc() call.
+ [ac_cv_func_calloc_0_nonnull=no],
+ [])
+ else
+ case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu* | gnu*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
+ # Guess yes on musl systems.
+ *-musl*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
+ # Guess yes on native Windows.
+ mingw*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
+ # If we don't know, obey --enable-cross-guesses.
+ *) ac_cv_func_calloc_0_nonnull="$gl_cross_guess_normal" ;;
+ esac
+ fi
+ ])
case "$ac_cv_func_calloc_0_nonnull" in
*yes)
$1

Return to:

Send suggestions and report system problems to the System administrator.