diff --git a/configure b/configure
index acb4592d8db679989aea86d762566097fb45e215..0a676a3fd2e7255663932f93b213f4d033e8d78e 100755
--- a/configure
+++ b/configure
@@ -14202,7 +14202,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
@@ -14214,12 +14213,14 @@ _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
+
 #include <math.h>
+double glob_double;
 
 int
 main ()
 {
-double x = 0.0; int res = isinf(x);
+return isinf(glob_double) ? 0 : 1;
   ;
   return 0;
 }
@@ -15102,11 +15103,14 @@ _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
+
 #include <math.h>
+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 5f7acd1871f2c364742c4904d24300cc1a330910..9ede74a7b43cdf540c500bc8c1e88ed48d9037e9 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.441 2006/01/05 03:01:32 momjian Exp $
+dnl $PostgreSQL: pgsql/configure.in,v 1.442 2006/01/12 19:23:22 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 <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])])
 
@@ -963,8 +964,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, [Define to 1 if you have finite().])
 AC_MSG_RESULT(yes)],
             [AC_MSG_RESULT(no)])