Skip to content

Commit fe1277f

Browse files
coryanfowles
authored andcommitted
fix: avoid warnings on Windows (#12701)
On Wndows, `size_t` is 64-bits, and `int` is 32-bits. That makes conversions from `size_t` to `int` potentially lossy, and they generate warnings. In this case an `int` variable was assigned to `size_t` and then passed to functions consuming `int`. Seems simpler to use `auto` and avoid these problems altogether. Closes #12701 COPYBARA_INTEGRATE_REVIEW=#12701 from coryan:fix-warnings-repeated-field-warnings-in-msvc b1ec34d PiperOrigin-RevId: 530134611
1 parent 28c9905 commit fe1277f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/google/protobuf/repeated_field.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ template <typename Element>
494494
inline RepeatedField<Element>::RepeatedField(const RepeatedField& rhs)
495495
: current_size_(0), total_size_(0), arena_or_elements_(nullptr) {
496496
StaticValidityCheck();
497-
if (size_t size = rhs.current_size_) {
497+
if (auto size = rhs.current_size_) {
498498
Grow(0, size);
499499
ExchangeCurrentSize(size);
500500
UninitializedCopyN(rhs.elements(), size, unsafe_elements());
@@ -775,7 +775,7 @@ inline void RepeatedField<Element>::Clear() {
775775
template <typename Element>
776776
inline void RepeatedField<Element>::MergeFrom(const RepeatedField& rhs) {
777777
ABSL_DCHECK_NE(&rhs, this);
778-
if (size_t size = rhs.current_size_) {
778+
if (auto size = rhs.current_size_) {
779779
Reserve(current_size_ + size);
780780
Element* dst = elements() + ExchangeCurrentSize(current_size_ + size);
781781
UninitializedCopyN(rhs.elements(), size, dst);

0 commit comments

Comments
 (0)