+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.
-# 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
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