diff options
author | Abseil Team <absl-team@google.com> | 2022-08-17 09:17:56 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-08-17 09:18:39 -0700 |
commit | fcfc7a6d15eab5aff86d7b90c9e38fa386a103fa (patch) | |
tree | ec697cf6574f311f9f373df7d19f307d9c185781 /absl/strings/internal/charconv_bigint.cc | |
parent | 934f613818ffcb26c942dff4a80be9a4031c662c (diff) |
Fix "unsafe narrowing" warnings in absl, 5/n.
Addresses failures with the following, in some files:
-Wshorten-64-to-32
-Wimplicit-int-conversion
-Wsign-compare
-Wsign-conversion
-Wtautological-unsigned-zero-compare
(This specific CL focuses on .cc files in strings/internal/.)
Bug: chromium:1292951
PiperOrigin-RevId: 468215101
Change-Id: I07fa487bcf2cf62d403489c3be7a5997cdef8987
Diffstat (limited to 'absl/strings/internal/charconv_bigint.cc')
-rw-r--r-- | absl/strings/internal/charconv_bigint.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/absl/strings/internal/charconv_bigint.cc b/absl/strings/internal/charconv_bigint.cc index ebf8c079..282b639e 100644 --- a/absl/strings/internal/charconv_bigint.cc +++ b/absl/strings/internal/charconv_bigint.cc @@ -242,7 +242,7 @@ int BigUnsigned<max_words>::ReadDigits(const char* begin, const char* end, // decimal exponent to compensate. --exponent_adjust; } - int digit = (*begin - '0'); + char digit = (*begin - '0'); --significant_digits; if (significant_digits == 0 && std::next(begin) != end && (digit == 0 || digit == 5)) { @@ -255,7 +255,7 @@ int BigUnsigned<max_words>::ReadDigits(const char* begin, const char* end, // 500000...000000000001 to correctly round up, rather than to nearest. ++digit; } - queued = 10 * queued + digit; + queued = 10 * queued + static_cast<uint32_t>(digit); ++digits_queued; if (digits_queued == kMaxSmallPowerOfTen) { MultiplyBy(kTenToNth[kMaxSmallPowerOfTen]); @@ -341,8 +341,8 @@ std::string BigUnsigned<max_words>::ToString() const { std::string result; // Build result in reverse order while (copy.size() > 0) { - int next_digit = copy.DivMod<10>(); - result.push_back('0' + next_digit); + uint32_t next_digit = copy.DivMod<10>(); + result.push_back('0' + static_cast<char>(next_digit)); } if (result.empty()) { result.push_back('0'); |