summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/bug229153
-rw-r--r--src/common/util.c16
2 files changed, 19 insertions, 0 deletions
diff --git a/changes/bug22915 b/changes/bug22915
new file mode 100644
index 0000000000..17a9c6018f
--- /dev/null
+++ b/changes/bug22915
@@ -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.
diff --git a/src/common/util.c b/src/common/util.c
index f53a99533b..5b47028097 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -5608,6 +5608,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;
@@ -5633,6 +5645,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