summaryrefslogtreecommitdiff
path: root/absl/strings/internal/str_format/float_conversion.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2018-07-25 09:37:23 -0700
committerGravatar Matt Calabrese <calabrese@x.team>2018-07-25 14:13:24 -0400
commitc2e00d341913bf03b4597ade5b056042e23e8c58 (patch)
treeafe60b3c7db3ca3769f74ee94cef26c116be4645 /absl/strings/internal/str_format/float_conversion.cc
parent9e060686d1c325f34f9806b45fe77bafeed00aee (diff)
Export of internal Abseil changes.
-- eb6cc81ef7e89e10fc9df47418af93e22fd116d2 by Abseil Team <absl-team@google.com>: Workaround clang bug https://bugs.llvm.org/show_bug.cgi?id=38289 PiperOrigin-RevId: 206006290 -- 509e9829295bfc429b82de42f2e073c756ea5709 by Jon Cohen <cohenjon@google.com>: Remove make_unique ambiguity when using gcc 4.9 in C++14 mode. gcc 4.9.4 has __cplusplus at 201300L instead of 201402L when in C++14 mode, I guess indicating incomplete support. Anyways, it causes a problem with this check as in c++14 mode in old gcc we were defining absl::make_unique when std::make_unique was present PiperOrigin-RevId: 205886589 GitOrigin-RevId: eb6cc81ef7e89e10fc9df47418af93e22fd116d2 Change-Id: I9acf3f3d0fd3b0b46ae099821f3bf21b72c28b2b
Diffstat (limited to 'absl/strings/internal/str_format/float_conversion.cc')
-rw-r--r--absl/strings/internal/str_format/float_conversion.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/absl/strings/internal/str_format/float_conversion.cc b/absl/strings/internal/str_format/float_conversion.cc
index 37952b46..6176db9c 100644
--- a/absl/strings/internal/str_format/float_conversion.cc
+++ b/absl/strings/internal/str_format/float_conversion.cc
@@ -153,7 +153,14 @@ void PrintExponent(int exp, char e, Buffer *out) {
template <typename Float, typename Int>
constexpr bool CanFitMantissa() {
- return std::numeric_limits<Float>::digits <= std::numeric_limits<Int>::digits;
+ return
+#if defined(__clang__) && !defined(__SSE3__)
+ // Workaround for clang bug: https://bugs.llvm.org/show_bug.cgi?id=38289
+ // Casting from long double to uint64_t is miscompiled and drops bits.
+ (!std::is_same<Float, long double>::value ||
+ !std::is_same<Int, uint64_t>::value) &&
+#endif
+ std::numeric_limits<Float>::digits <= std::numeric_limits<Int>::digits;
}
template <typename Float>