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/str_format/bind.cc | |
parent | 934f613818ffcb26c942dff4a80be9a4031c662c (diff) | |
download | abseil-fcfc7a6d15eab5aff86d7b90c9e38fa386a103fa.tar.gz abseil-fcfc7a6d15eab5aff86d7b90c9e38fa386a103fa.tar.bz2 abseil-fcfc7a6d15eab5aff86d7b90c9e38fa386a103fa.zip |
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/str_format/bind.cc')
-rw-r--r-- | absl/strings/internal/str_format/bind.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/absl/strings/internal/str_format/bind.cc b/absl/strings/internal/str_format/bind.cc index c988ba8f..77a42223 100644 --- a/absl/strings/internal/str_format/bind.cc +++ b/absl/strings/internal/str_format/bind.cc @@ -32,7 +32,8 @@ inline bool BindFromPosition(int position, int* value, return false; } // -1 because positions are 1-based - return FormatArgImplFriend::ToInt(pack[position - 1], value); + return FormatArgImplFriend::ToInt(pack[static_cast<size_t>(position) - 1], + value); } class ArgContext { @@ -56,7 +57,7 @@ inline bool ArgContext::Bind(const UnboundConversion* unbound, const FormatArgImpl* arg = nullptr; int arg_position = unbound->arg_position; if (static_cast<size_t>(arg_position - 1) >= pack_.size()) return false; - arg = &pack_[arg_position - 1]; // 1-based + arg = &pack_[static_cast<size_t>(arg_position - 1)]; // 1-based if (unbound->flags != Flags::kBasic) { int width = unbound->width.value(); |