[tor-commits] [tor/maint-0.3.1] Only disable -Wfloat-conversion on mingw when it exists.

nickm at torproject.org nickm at torproject.org
Wed Jul 5 20:12:02 UTC 2017


commit dfc06148407a1610d515d45b344558850486bd98
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Jul 5 16:10:45 2017 -0400

    Only disable -Wfloat-conversion on mingw when it exists.
    
    The 22081 fix disabled -Wfloat-conversion, but -Wfloat-conversion
    didn't exist in every relevant mingw; it was added in GCC 4.9.x some
    time, if the documentation can be trusted.
    
    Bug not in any released version of tor.
---
 src/common/util.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/common/util.c b/src/common/util.c
index b7468df..9e61eb7 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -5695,13 +5695,14 @@ clamp_double_to_int64(double number)
 {
   int exponent;
 
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if (defined(__MINGW32__) || defined(__MINGW64__)) && GCC_VERSION >= 409
 /*
   Mingw's math.h uses gcc's __builtin_choose_expr() facility to declare
   isnan, isfinite, and signbit.  But as implemented in at least some
   versions of gcc, __builtin_choose_expr() can generate type warnings
   even from branches that are not taken.  So, suppress those warnings.
 */
+#define PROBLEMATIC_FLOAT_CONVERSION_WARNING
 DISABLE_GCC_WARNING(float-conversion)
 #endif
   /* NaN is a special case that can't be used with the logic below. */
@@ -5729,7 +5730,7 @@ DISABLE_GCC_WARNING(float-conversion)
 
   /* Handle infinities and finite numbers with magnitude >= 2^63. */
   return signbit(number) ? INT64_MIN : INT64_MAX;
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#ifdef PROBLEMATIC_FLOAT_CONVERSION_WARNING
 ENABLE_GCC_WARNING(float-conversion)
 #endif
 }





More information about the tor-commits mailing list