]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix -Wfloat-conversion C warnings on mingw in clamp_double_to_int64.
authorNick Mathewson <nickm@torproject.org>
Mon, 3 Jul 2017 14:59:31 +0000 (10:59 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 3 Jul 2017 14:59:31 +0000 (10:59 -0400)
We just have to suppress these warnings: 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.

Fixes bug 22801; bugfix on 0.2.8.1-alpha.

changes/bug22801 [new file with mode: 0644]
src/common/util.c

diff --git a/changes/bug22801 b/changes/bug22801
new file mode 100644 (file)
index 0000000..7edc79b
--- /dev/null
@@ -0,0 +1,5 @@
+  o Minor bugfixes (compilation):
+    - When building with certain versions the mingw C header files, avoid
+      float-conversion warnings when calling the C functions isfinite(),
+      isnan(), and signbit(). Fixes bug 22801; bugfix on 0.2.8.1-alpha.
+
index f3effe0957b1bd384ca05dcbd06816f54b570af4..b2b97613a7ea6520d29db35e690a76e8df929b36 100644 (file)
@@ -5537,6 +5537,15 @@ clamp_double_to_int64(double number)
 {
   int exp;
 
+#if defined(__MINGW32__) || defined(__MINGW64__)
+/*
+  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.
+*/
+DISABLE_GCC_WARNING(float-conversion)
+#endif
   /* NaN is a special case that can't be used with the logic below. */
   if (isnan(number)) {
     return 0;
@@ -5562,5 +5571,8 @@ clamp_double_to_int64(double number)
 
   /* Handle infinities and finite numbers with magnitude >= 2^63. */
   return signbit(number) ? INT64_MIN : INT64_MAX;
+#if defined(__MINGW32__) || defined(__MINGW64__)
+ENABLE_GCC_WARNING(float-conversion)
+#endif
 }