diff --git a/configure b/configure index 4c789bd9289..f69331f0748 100755 --- a/configure +++ b/configure @@ -7700,29 +7700,6 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext -# Defend against gcc -ffast-math -if test "$GCC" = yes; then -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifdef __FAST_MATH__ -choke me -#endif - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - as_fn_error $? "do not put -ffast-math in CFLAGS" "$LINENO" 5 -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - # Defend against clang being used on x86-32 without SSE2 enabled. As current # versions of clang do not understand -fexcess-precision=standard, the use of # x87 floating point operations leads to problems like isinf possibly returning diff --git a/configure.ac b/configure.ac index 9edffe481a6..fead9a6ce99 100644 --- a/configure.ac +++ b/configure.ac @@ -786,13 +786,6 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])], [AC_MSG_RESULT(no) AC_MSG_ERROR([cannot proceed])]) -# Defend against gcc -ffast-math -if test "$GCC" = yes; then -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [@%:@ifdef __FAST_MATH__ -choke me -@%:@endif])], [], [AC_MSG_ERROR([do not put -ffast-math in CFLAGS])]) -fi - # Defend against clang being used on x86-32 without SSE2 enabled. As current # versions of clang do not understand -fexcess-precision=standard, the use of # x87 floating point operations leads to problems like isinf possibly returning diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index 621b9175c12..87c063fa0cd 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -38,14 +38,6 @@ #include "utils/skipsupport.h" #include "utils/sortsupport.h" -/* - * gcc's -ffast-math switch breaks routines that expect exact results from - * expressions like timeval / SECS_PER_HOUR, where timeval is double. - */ -#ifdef __FAST_MATH__ -#error -ffast-math is known to break this code -#endif - /* common code for timetypmodin and timetztypmodin */ static int32 diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index 641e7de21a0..f77f73820d7 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -29,6 +29,23 @@ #include "utils/sortsupport.h" +/* + * Reject building with gcc's -ffast-math switch. It breaks our handling of + * float Infinity and NaN values (via -ffinite-math-only), causes results to + * be less accurate than expected (via -funsafe-math-optimizations and + * -fexcess-precision=fast), and causes some math error reports to be missed + * (via -fno-math-errno). Unfortunately we can't easily detect cases where + * those options were given individually, but this at least catches the most + * obvious case. + * + * We test this only here, not in any header file, to allow extensions to use + * -ffast-math if they need to. But the inline functions in float.h will + * misbehave in such an extension, so its authors had better be careful. + */ +#ifdef __FAST_MATH__ +#error -ffast-math is known to break this code +#endif + /* * Configurable GUC parameter * diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 6f8cf29c910..50a73fd24ec 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -40,13 +40,6 @@ #include "utils/skipsupport.h" #include "utils/sortsupport.h" -/* - * gcc's -ffast-math switch breaks routines that expect exact results from - * expressions like timeval / SECS_PER_HOUR, where timeval is double. - */ -#ifdef __FAST_MATH__ -#error -ffast-math is known to break this code -#endif /* Set at postmaster start */ TimestampTz PgStartTime; diff --git a/src/interfaces/ecpg/pgtypeslib/interval.c b/src/interfaces/ecpg/pgtypeslib/interval.c index e452a088f9e..463455398f1 100644 --- a/src/interfaces/ecpg/pgtypeslib/interval.c +++ b/src/interfaces/ecpg/pgtypeslib/interval.c @@ -6,10 +6,6 @@ #include #include -#ifdef __FAST_MATH__ -#error -ffast-math is known to break this code -#endif - #include "common/string.h" #include "dt.h" #include "pgtypes_error.h" diff --git a/src/interfaces/ecpg/pgtypeslib/timestamp.c b/src/interfaces/ecpg/pgtypeslib/timestamp.c index 7cf433266f4..9bf1b914553 100644 --- a/src/interfaces/ecpg/pgtypeslib/timestamp.c +++ b/src/interfaces/ecpg/pgtypeslib/timestamp.c @@ -7,10 +7,6 @@ #include #include -#ifdef __FAST_MATH__ -#error -ffast-math is known to break this code -#endif - #include "common/int.h" #include "dt.h" #include "pgtypes_date.h"