[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.4.0] fp.c: Suppress float-conversion warnings on FreeBSD.



commit 51475aee57523318d0b0a9e47dedad89ef1b578c
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Sep 10 10:53:39 2019 -0400

    fp.c: Suppress float-conversion warnings on FreeBSD.
    
    We used to do this on Windows only, but it appears to affect
    multiple platforms when building with certain versions of GCC, and a
    common pattern for defining the floating-point classifier functions.
    
    Fixes part of 31687. I'm calling this a bugfux on 31687, when we
    started suppressing these warnings on Windows.
---
 changes/ticket31687_1 | 4 ++++
 src/lib/math/fp.c     | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/changes/ticket31687_1 b/changes/ticket31687_1
new file mode 100644
index 000000000..2f4d44097
--- /dev/null
+++ b/changes/ticket31687_1
@@ -0,0 +1,4 @@
+  o Minor bugfixes (compilation):
+    - Suppress spurious float-conversion warnings from GCC when calling
+      floating-point classifier functions on FreeBSD.  Fixes part of bug
+      31687; bugfix on 0.3.1.5-alpha.
diff --git a/src/lib/math/fp.c b/src/lib/math/fp.c
index 4419635df..eafad358c 100644
--- a/src/lib/math/fp.c
+++ b/src/lib/math/fp.c
@@ -62,12 +62,16 @@ clamp_double_to_int64(double number)
 {
   int exponent;
 
-#if defined(MINGW_ANY) && GCC_VERSION >= 409
+#if (defined(MINGW_ANY)||defined(__FreeBSD__)) && 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.
+
+  FreeBSD's math.h uses an __fp_type_select() macro, which dispatches
+  based on sizeof -- again, this can generate type warnings from
+  branches that are not taken.
 */
 #define PROBLEMATIC_FLOAT_CONVERSION_WARNING
 DISABLE_GCC_WARNING(float-conversion)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits