From b1ec34de77cbd31c914b810c87cbe16f1ce51a7d Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Sat, 6 May 2023 19:26:10 +0000 Subject: [PATCH] fix: avoid warnings on Windows 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. --- src/google/protobuf/repeated_field.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index eba9868929c6..85ed0b2691eb 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -505,7 +505,7 @@ template inline RepeatedField::RepeatedField(const RepeatedField& rhs) : current_size_(0), total_size_(0), arena_or_elements_(nullptr) { StaticValidityCheck(); - if (size_t size = rhs.current_size_) { + if (auto size = rhs.current_size_) { Grow(0, size); ExchangeCurrentSize(size); UninitializedCopyN(rhs.elements(), size, unsafe_elements()); @@ -786,7 +786,7 @@ inline void RepeatedField::Clear() { template inline void RepeatedField::MergeFrom(const RepeatedField& rhs) { ABSL_DCHECK_NE(&rhs, this); - if (size_t size = rhs.current_size_) { + if (auto size = rhs.current_size_) { Reserve(current_size_ + size); Element* dst = elements() + ExchangeCurrentSize(current_size_ + size); UninitializedCopyN(rhs.elements(), size, dst);