protocolbuffers/protobuf

Warning in repeated_ptr_field.h about conversion from `size_t` to `int` causes compiler error

Aberta

#23.248 aberto em 27 de ago. de 2025

 (1 comentário) (0 reação) (1 responsável)C++ (16.128 forks)batch import
help wanted

Métricas do repositório

Stars
 (71.223 estrelas)
Métricas de merge de PR
 (Mesclagem média 2d 11h) (185 fundiu PRs em 30d)

Description

What version of protobuf and what language are you using? Version: main/v6.30.1 Language: C++

What operating system (Linux, Windows, ...) and version?

Windows

What runtime / compiler are you using (e.g., python version or gcc version)

MSVC 17.12.5

What did you do? I am compiling code that includes a generated .pb.h file.

What did you expect to see What did you see instead?

I am running into compiler warnings, which are treated as errors:

C:\dev\conan-cache\p\protoee6b55d34d238\p\include\google/protobuf/repeated_ptr_field.h(1575): error C2220: the following warning is treated as an error
C:\dev\conan-cache\p\protoee6b55d34d238\p\include\google/protobuf/repeated_ptr_field.h(1575): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
C:\dev\conan-cache\p\protoee6b55d34d238\p\include\google/protobuf/repeated_ptr_field.h(1580): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
C:\dev\conan-cache\p\protoee6b55d34d238\p\include\google/protobuf/repeated_ptr_field.h(1584): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
C:\dev\conan-cache\p\protoee6b55d34d238\p\include\google/protobuf/repeated_field.h(145): warning C4267: 'argument': conversion from 'size_t' to 'const _Ty', possible loss of data

I believe that this issue still exists in the codebase:

Anything else we should know about your project / environment

Guia do colaborador