Skip to content

Resolve different signedness warning #21944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

iksrandeb
Copy link

The size() by default returns an unsigned integer datatype. In other places in this code a C cast style is used. Follow the same resolution, and cast the unsigned integer type to signed integer.

The size() by default returns an unsigned integer datatype. In other places in
this code a C cast style is used. Follow the same resolution, and cast the unsigned
integer type to signed integer.
@iksrandeb iksrandeb requested a review from a team as a code owner May 24, 2025 09:26
@iksrandeb iksrandeb requested review from googleberg and removed request for a team May 24, 2025 09:26
Copy link

google-cla bot commented May 24, 2025

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.

@iksrandeb
Copy link
Author

Proposal for solving #21938

@@ -177,7 +177,7 @@ void GenerateLarge(
}},
{"aliases",
[&] {
for (int i = 0; i < aliases.size(); i++) {
for (int i = 0; i < (int)aliases.size(); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about size_t i = 0; without the cast?

Copy link
Author

@iksrandeb iksrandeb Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with the proposal of size_t. However the rest of the code in this file uses a C cast and I just wanted to be consistent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbenzaquen wdyt?

Copy link
Author

@iksrandeb iksrandeb Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the suggested solution size_t i = 0; without the cast.

The size() by default returns size_t datatype. Update the data type for
the loop iterator to resolve compiler warning for signedness mismatch.
@mkruskal-google mkruskal-google added cleanup protoc 🅰️ safe for tests Mark a commit as safe to run presubmits over labels Jun 9, 2025
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants