diff options
author | Vincent Ambo <tazjin@google.com> | 2020-06-17T13·53+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-06-17T13·53+0100 |
commit | 543379ce4572a4015c62812f93acb02938caece1 (patch) | |
tree | 797b0cbcc4795bbc73d9d5b2913e06156fa8614a /third_party/abseil_cpp/absl/strings/internal | |
parent | c224a738e7524fd0b6c8bed134f43b307bdbc9e8 (diff) | |
parent | 8f2828c4b4ce502d242eca80a80269448857f4a6 (diff) |
merge(3p/abseil_cpp): Merge upstream at 'ccdbb5941' r/1011
Change-Id: I6e85fc7b5f76bba1f1eef15e600a8acb64e97ef5
Diffstat (limited to 'third_party/abseil_cpp/absl/strings/internal')
-rw-r--r-- | third_party/abseil_cpp/absl/strings/internal/str_format/convert_test.cc | 6 | ||||
-rw-r--r-- | third_party/abseil_cpp/absl/strings/internal/str_format/float_conversion.cc | 12 |
2 files changed, 12 insertions, 6 deletions
diff --git a/third_party/abseil_cpp/absl/strings/internal/str_format/convert_test.cc b/third_party/abseil_cpp/absl/strings/internal/str_format/convert_test.cc index 20c6229fcb37..0e8535c27b7a 100644 --- a/third_party/abseil_cpp/absl/strings/internal/str_format/convert_test.cc +++ b/third_party/abseil_cpp/absl/strings/internal/str_format/convert_test.cc @@ -764,6 +764,12 @@ TEST_F(FormatConvertTest, LongDouble) { } } + // Regression tests + // + // Using a string literal because not all platforms support hex literals or it + // might be out of range. + doubles.push_back(std::strtold("-0xf.ffffffb5feafffbp-16324L", nullptr)); + for (const char *fmt : kFormats) { for (char f : {'f', 'F', // 'g', 'G', // diff --git a/third_party/abseil_cpp/absl/strings/internal/str_format/float_conversion.cc b/third_party/abseil_cpp/absl/strings/internal/str_format/float_conversion.cc index a761a5a5f9ce..10e4695411b2 100644 --- a/third_party/abseil_cpp/absl/strings/internal/str_format/float_conversion.cc +++ b/third_party/abseil_cpp/absl/strings/internal/str_format/float_conversion.cc @@ -224,13 +224,13 @@ class FractionalDigitGenerator { // This function will allocate enough stack space to perform the conversion. static void RunConversion( uint128 v, int exp, absl::FunctionRef<void(FractionalDigitGenerator)> f) { + using Limits = std::numeric_limits<long double>; assert(-exp < 0); - assert(-exp >= std::numeric_limits<long double>::min_exponent - 128); - static_assert( - StackArray::kMaxCapacity >= - (128 - std::numeric_limits<long double>::min_exponent + 31) / 32, - ""); - StackArray::RunWithCapacity((exp + 31) / 32, + assert(-exp >= Limits::min_exponent - 128); + static_assert(StackArray::kMaxCapacity >= + (Limits::digits + 128 - Limits::min_exponent + 31) / 32, + ""); + StackArray::RunWithCapacity((Limits::digits + exp + 31) / 32, [=](absl::Span<uint32_t> input) { f(FractionalDigitGenerator(input, v, exp)); }); |