Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit db0558c

Browse files
committed
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.
1 parent 9484e14 commit db0558c

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

configure

+7-3
Original file line numberDiff line numberDiff line change
@@ -14202,7 +14202,6 @@ fi
1420214202

1420314203

1420414204

14205-
# do this one the hard way in case isinf() is a macro
1420614205
echo "$as_me:$LINENO: checking for isinf" >&5
1420714206
echo $ECHO_N "checking for isinf... $ECHO_C" >&6
1420814207
if test "${ac_cv_func_isinf+set}" = set; then
@@ -14214,12 +14213,14 @@ _ACEOF
1421414213
cat confdefs.h >>conftest.$ac_ext
1421514214
cat >>conftest.$ac_ext <<_ACEOF
1421614215
/* end confdefs.h. */
14216+
1421714217
#include <math.h>
14218+
double glob_double;
1421814219

1421914220
int
1422014221
main ()
1422114222
{
14222-
double x = 0.0; int res = isinf(x);
14223+
return isinf(glob_double) ? 0 : 1;
1422314224
;
1422414225
return 0;
1422514226
}
@@ -15102,11 +15103,14 @@ _ACEOF
1510215103
cat confdefs.h >>conftest.$ac_ext
1510315104
cat >>conftest.$ac_ext <<_ACEOF
1510415105
/* end confdefs.h. */
15106+
1510515107
#include <math.h>
15108+
double glob_double;
15109+
1510615110
int
1510715111
main ()
1510815112
{
15109-
int dummy=finite(1.0);
15113+
return finite(glob_double) ? 0 : 1;
1511015114
;
1511115115
return 0;
1511215116
}

configure.in

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.441 2006/01/05 03:01:32 momjian Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.442 2006/01/12 19:23:22 tgl Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -892,12 +892,13 @@ fi
892892
AC_CHECK_DECLS([snprintf, vsnprintf])
893893

894894

895-
# do this one the hard way in case isinf() is a macro
895+
dnl Cannot use AC_CHECK_FUNC because isinf may be a macro
896896
AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
897-
[AC_TRY_LINK(
898-
[#include <math.h>
897+
[AC_TRY_LINK([
898+
#include <math.h>
899+
double glob_double;
899900
],
900-
[double x = 0.0; int res = isinf(x);],
901+
[return isinf(glob_double) ? 0 : 1;],
901902
[ac_cv_func_isinf=yes],
902903
[ac_cv_func_isinf=no])])
903904

@@ -963,8 +964,11 @@ fi
963964

964965
dnl Cannot use AC_CHECK_FUNC because finite may be a macro
965966
AC_MSG_CHECKING(for finite)
966-
AC_TRY_LINK([#include <math.h>],
967-
[int dummy=finite(1.0);],
967+
AC_TRY_LINK([
968+
#include <math.h>
969+
double glob_double;
970+
],
971+
[return finite(glob_double) ? 0 : 1;],
968972
[AC_DEFINE(HAVE_FINITE, 1, [Define to 1 if you have finite().])
969973
AC_MSG_RESULT(yes)],
970974
[AC_MSG_RESULT(no)])

0 commit comments

Comments
 (0)