Skip to content

Fix MSVC conversion and shadowing warnings (C4267, C4458) - #29235

Open
arman-martirosyan wants to merge 1 commit into
protocolbuffers:mainfrom
arman-martirosyan:msvc-warning-fixes
Open

Fix MSVC conversion and shadowing warnings (C4267, C4458)#29235
arman-martirosyan wants to merge 1 commit into
protocolbuffers:mainfrom
arman-martirosyan:msvc-warning-fixes

Conversation

@arman-martirosyan

Copy link
Copy Markdown

Make size_t narrowing conversions explicit with static_cast and rename shadowing parameters.

The casts are safe because the values are bounded by the fields they are assigned to: MicroString sizes are limited by the uint32_t capacity field, map hashes intentionally truncate to map_index_t, and RepeatedPtrField indices and sizes are int internally.

This fixes MSVC warnings C4267 in micro_string.h, map.h and repeated_ptr_field.h and C4458 in micro_string.h for every consumer that compiles these headers at a high warning level (/W4).

@google-cla

google-cla Bot commented Aug 18, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Make size_t narrowing conversions explicit with static_cast and rename
shadowing parameters. The casts are safe because the values are bounded
by the fields they are assigned to: MicroString sizes are limited by
the uint32_t capacity field, map hashes intentionally truncate to
map_index_t, and RepeatedPtrField indices and sizes are int internally.

Fixes MSVC C4267 in micro_string.h, map.h and repeated_ptr_field.h and
C4458 in micro_string.h for every consumer compiling with a high
warning level (/W4).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant