]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Suppress clang4-specific -Wdouble-promotion warnings
authorNick Mathewson <nickm@torproject.org>
Thu, 13 Jul 2017 21:42:04 +0000 (17:42 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 26 Jul 2017 16:53:00 +0000 (12:53 -0400)
Wow, it sure seems like some compilers can't implement isnan() and
friends in a way that pleases themselves!

Fixes bug 22915. Bug trigged by 0.2.8.1-alpha and later; caused by
clang 4.

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

diff --git a/changes/bug22915 b/changes/bug22915
new file mode 100644 (file)
index 0000000..17a9c60
--- /dev/null
@@ -0,0 +1,3 @@
+  o Minor bugfixes (compilation warnings):
+    - Suppress -Wdouble-promotion warnings with clang 4.0. Fixes bug 22915;
+      bugfix on 0.2.8.1-alpha.
index 9e61eb77103df20769abc122915287a00cc0747b..d2cbacde31a0963569be17938482deba9a88984e 100644 (file)
@@ -5705,6 +5705,18 @@ clamp_double_to_int64(double number)
 #define PROBLEMATIC_FLOAT_CONVERSION_WARNING
 DISABLE_GCC_WARNING(float-conversion)
 #endif
+
+/*
+  With clang 4.0 we apparently run into "double promotion" warnings here,
+  since clang thinks we're promoting a double to a long double.
+ */
+#if defined(__clang__)
+#if __has_warning("-Wdouble-promotion")
+#define PROBLEMATIC_DOUBLE_PROMOTION_WARNING
+DISABLE_GCC_WARNING(double-promotion)
+#endif
+#endif
+
   /* NaN is a special case that can't be used with the logic below. */
   if (isnan(number)) {
     return 0;
@@ -5730,6 +5742,10 @@ DISABLE_GCC_WARNING(float-conversion)
 
   /* Handle infinities and finite numbers with magnitude >= 2^63. */
   return signbit(number) ? INT64_MIN : INT64_MAX;
+
+#ifdef PROBLEMATIC_DOUBLE_PROMOTION_WARNING
+ENABLE_GCC_WARNING(double-promotion)
+#endif
 #ifdef PROBLEMATIC_FLOAT_CONVERSION_WARNING
 ENABLE_GCC_WARNING(float-conversion)
 #endif