Skip to content
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

Prevent MSVC warning C26451: Arithmetic overflow for clove-unit.h #112

Merged

Conversation

vbaderks
Copy link
Contributor

@vbaderks vbaderks commented Nov 3, 2024

MSVC will report, when static analyzer warnings are enabled:
C26451: Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2).

As last_char_index + 1 fits normally in an int, there is no risk to overflow, but the warning is annoying. Fix the warning by first doing the cast and then adding 1.

MSVC will report, when static analyzer warnings are enabled:
C26451: Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2).

As last_char_index + 1 fits normally in an int, there is no risk to overflow, but the warning is anoying.
Fix the warning by first doing the cast and then adding 1.
@fdefelici fdefelici changed the base branch from master to release_v2.4.6 November 10, 2024 15:15
@fdefelici fdefelici self-assigned this Nov 10, 2024
@fdefelici fdefelici merged commit daa1649 into fdefelici:release_v2.4.6 Nov 10, 2024
11 checks passed
@fdefelici
Copy link
Owner

close #112

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.

2 participants