Skip to content

Conversation

@ElMostafaIdrassi
Copy link
Contributor

MSVC emits C4146 on the (- static_cast<uint32_t>(flg0)) & mask13; and -(t0 >> 31) expressions in the barrett_reduce() and reduce_once() functions respectively, despite them being valid two’s-complement negations.
If the /sdl option is enabled (which is by default in MSVC 2022), this warning becomes an error.

By replacing the unary minus with an explicit unsigned subtraction, we can silence the warnings/errors while preserving the constant-expression, branchless behavior.

@itzmeanjan
Copy link
Owner

Thanks again for the PR, I'll have a look. For now running the CI.

@itzmeanjan itzmeanjan self-requested a review June 24, 2025 16:25
@itzmeanjan
Copy link
Owner

Looks good, merging it. Thanks for addressing the issue.

@itzmeanjan itzmeanjan merged commit 7fe950a into itzmeanjan:master Jun 24, 2025
24 checks passed
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