diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-07-13 17:42:04 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-07-26 12:53:00 -0400 |
commit | fca1934c88f1238a43d0bea5b06cea4fd15e7b93 (patch) | |
tree | 95de9b480115247b6287c00f1722017d17ba2723 /src/common/util.c | |
parent | ed0fb218342dcf7cc54f6abd9078dcd3efa5452c (diff) | |
download | tor-fca1934c88f1238a43d0bea5b06cea4fd15e7b93.tar.gz tor-fca1934c88f1238a43d0bea5b06cea4fd15e7b93.zip |
Suppress clang4-specific -Wdouble-promotion warnings
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.
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index 9e61eb7710..d2cbacde31 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -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 |