From: Tom Lane Date: Thu, 12 Jan 2006 19:23:41 +0000 (+0000) Subject: Use a more bulletproof test for whether finite() and isinf() are present. X-Git-Tag: REL8_1_3~54 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2c60a2cfe3b8f12564133d18d62d6dece12c63f;p=postgresql 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. --- diff --git a/configure b/configure index 60270b638d..52a1605cff 100755 --- a/configure +++ b/configure @@ -14241,7 +14241,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 @@ -14253,12 +14252,14 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ + #include +double glob_double; int main () { -double x = 0.0; int res = isinf(x); +return isinf(glob_double) ? 0 : 1; ; return 0; } @@ -15138,11 +15139,14 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ + #include +double glob_double; + int main () { -int dummy=finite(1.0); +return finite(glob_double) ? 0 : 1; ; return 0; } diff --git a/configure.in b/configure.in index c57e93282a..572f9d2265 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -dnl $PostgreSQL: pgsql/configure.in,v 1.431.2.5 2006/01/05 04:02:23 momjian Exp $ +dnl $PostgreSQL: pgsql/configure.in,v 1.431.2.6 2006/01/12 19:23:41 tgl Exp $ dnl dnl Developers, please strive to achieve this order: dnl @@ -892,12 +892,13 @@ fi 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 +[AC_TRY_LINK([ +#include +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])]) @@ -960,8 +961,11 @@ fi dnl Cannot use AC_CHECK_FUNC because finite may be a macro AC_MSG_CHECKING(for finite) -AC_TRY_LINK([#include ], - [int dummy=finite(1.0);], +AC_TRY_LINK([ +#include +double glob_double; +], + [return finite(glob_double) ? 0 : 1;], [AC_DEFINE(HAVE_FINITE, 1, [Define to 1 if you have finite().]) AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])