Address C4244 warnings in MSVC build#852
Closed
GrabYourPitchforks wants to merge 1 commit intomadler:developfrom
Closed
Address C4244 warnings in MSVC build#852GrabYourPitchforks wants to merge 1 commit intomadler:developfrom
GrabYourPitchforks wants to merge 1 commit intomadler:developfrom
Conversation
This was referenced Aug 30, 2023
Contributor
|
Interesting, so this is affecting dotnet/runtime? I wonder how my vc17 changes affect dotnet/runtime by chance. |
Contributor
Author
It affects our ability to enable more C++ warnings as errors within our build. We've already made these changes locally so that we can re-enable the warning codes, but I'm sending them back upstream in case the project maintainer wants to take them. As far as I can tell there's no behavioral change. |
Contributor
|
Alright thanks, I was wondering if it would affect dotnet/runtime in a good way as well. |
Owner
|
Incorporated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allows the MSVC build to compile clean when the C4244 warning code (checking for potentially lossy implicit integer narrowing casts) is enabled. I've tried to follow the same coding convention as was used in 3df8424.
An analysis our review team performed to convince ourselves of the correctness of the changes...
The change to deflate.c is legal because 'len' has an upper bound of MAX_STORED, which means it fits cleanly into a 16-bit integer. So writing out 2x 8-bit values will not result in data loss.
The change to trees.c is legal because within this loop, 'count' is intended to have an upper bound of 138, with the target assignment only executing if 'count' is bounded by 4. Neither the 'count' local in isolation nor the addition that's part of the target line is expected to result in integer overflow. But even if it did, that's a matter for a different warning code and doesn't impact the correctness of the narrowing cast being considered here.