From 1937d8d9efcc0444525a8eb1f6fbc11fddb9512d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 12 Jan 2006 19:24:27 +0000 Subject: [PATCH] =?UTF-8?q?Use=20a=20more=20bulletproof=20test=20for=20whe?= =?UTF-8?q?ther=20finite()=20and=20isinf()=20are=20present.=20It=20seems?= =?UTF-8?q?=20that=20recent=20gcc=20versions=20can=20optimize=20away=20cal?= =?UTF-8?q?ls=20to=20these=20functions=20even=20when=20the=20functions=20d?= =?UTF-8?q?o=20not=20exist=20on=20the=20platform,=20resulting=20in=20a=20b?= =?UTF-8?q?ogus=20positive=20result.=20=20Avoid=20this=20by=20using=20a=20?= =?UTF-8?q?non-constant=20argument=20and=20ensuring=20that=20the=20functio?= =?UTF-8?q?n=20result=20is=20not=20simply=20discarded.=20=20Per=20report?= =?UTF-8?q?=20from=20Fran=C3=A7ois=20Laupretre.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configure | 10 +++++++--- configure.in | 18 +++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/configure b/configure index f6823dce786..d3b61a8a417 100755 --- a/configure +++ b/configure @@ -11819,7 +11819,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 @@ -11828,7 +11827,9 @@ else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" + #include +double glob_double; #ifdef F77_DUMMY_MAIN # ifdef __cplusplus @@ -11839,7 +11840,7 @@ else int main () { -double x = 0.0; int res = isinf(x); +return isinf(glob_double) ? 0 : 1; ; return 0; } @@ -12454,7 +12455,10 @@ echo $ECHO_N "checking for finite... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" + #include +double glob_double; + #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" @@ -12464,7 +12468,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 94b0a5085d6..8462fffc434 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.301.2.18 2006/01/05 03:59:47 momjian Exp $ +dnl $Header: /cvsroot/pgsql/configure.in,v 1.301.2.19 2006/01/12 19:24:26 tgl Exp $ dnl dnl Developers, please strive to achieve this order: dnl @@ -912,12 +912,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 +[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])]) @@ -974,8 +975,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)])