summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2006-01-12 19:24:48 +0000
committerTom Lane2006-01-12 19:24:48 +0000
commit158c7f32b497af31943162250b548897a797be72 (patch)
treeb2d9d9014f6acb5d1a4dd72c7c7effabd1bd0b0b
parentb4feb29e0de7b583cbad57b076a9a63b81d12695 (diff)
Use a more bulletproof test for whether finite() and isinf() are present.
It seems that recent gcc versions can optimize away calls to these functions even when the functions do not exist on the platform, resulting in a bogus positive result. Avoid this by using a non-constant argument and ensuring that the function result is not simply discarded. Per report from François Laupretre.
-rwxr-xr-xconfigure10
-rw-r--r--configure.in18
2 files changed, 18 insertions, 10 deletions
diff --git a/configure b/configure
index 0fb9504cef7..754da60eaea 100755
--- a/configure
+++ b/configure
@@ -10382,7 +10382,6 @@ fi
-# do this one the hard way in case isinf() is a macro
echo "$as_me:$LINENO: checking for isinf" >&5
echo $ECHO_N "checking for isinf... $ECHO_C" >&6
if test "${ac_cv_func_isinf+set}" = set; then
@@ -10391,7 +10390,9 @@ else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
+
#include <math.h>
+double glob_double;
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
@@ -10402,7 +10403,7 @@ else
int
main ()
{
-double x = 0.0; int res = isinf(x);
+return isinf(glob_double) ? 0 : 1;
;
return 0;
}
@@ -10913,7 +10914,10 @@ echo $ECHO_N "checking for finite... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
+
#include <math.h>
+double glob_double;
+
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
extern "C"
@@ -10923,7 +10927,7 @@ cat >conftest.$ac_ext <<_ACEOF
int
main ()
{
-int dummy=finite(1.0);
+return finite(glob_double) ? 0 : 1;
;
return 0;
}
diff --git a/configure.in b/configure.in
index 117243adac4..0f740d4e330 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
-dnl $Header: /cvsroot/pgsql/configure.in,v 1.217.2.21 2006/01/05 03:59:19 momjian Exp $
+dnl $Header: /cvsroot/pgsql/configure.in,v 1.217.2.22 2006/01/12 19:24:47 tgl Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
@@ -823,12 +823,13 @@ AC_CHECK_FUNCS(vsnprintf, [], pgac_need_repl_snprintf=yes)
AC_CHECK_DECLS([snprintf, vsnprintf])
-# do this one the hard way in case isinf() is a macro
+dnl Cannot use AC_CHECK_FUNC because isinf may be a macro
AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
-[AC_TRY_LINK(
-[#include <math.h>
+[AC_TRY_LINK([
+#include <math.h>
+double glob_double;
],
-[double x = 0.0; int res = isinf(x);],
+[return isinf(glob_double) ? 0 : 1;],
[ac_cv_func_isinf=yes],
[ac_cv_func_isinf=no])])
@@ -877,8 +878,11 @@ fi
dnl Cannot use AC_CHECK_FUNC because finite may be a macro
AC_MSG_CHECKING(for finite)
-AC_TRY_LINK([#include <math.h>],
- [int dummy=finite(1.0);],
+AC_TRY_LINK([
+#include <math.h>
+double glob_double;
+],
+ [return finite(glob_double) ? 0 : 1;],
[AC_DEFINE(HAVE_FINITE, 1, [Set to 1 if you have finite()])
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])