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

Fixed MSVC warning about conditional expression being constant #261

Conversation

noodlecollie
Copy link

This is because the condition expands out to 1 != 0 if HASH_BLOOM is not defined. Instead, I've modified the HASH_BLOOM_TEST macro to include the != 0 when the left hand side will not just be 1, and leave the comparison as 1 otherwise - apparently MSVC thinks if ( 1 ) is fine.

Quuxplusone added a commit to Quuxplusone/uthash that referenced this pull request May 14, 2024
MSVC `-W4` gives "warning C4127: conditional expression is constant"
for `if (1 != 0)`, but no warning for `if (1)`. Use the latter instead
of the former. In fact, the comparison against zero should really be
all the way down in `HASH_BLOOM_BITTEST`.

No functional change intended.

Thanks to @noodlecollie for the patch!
@Quuxplusone
Copy link
Collaborator

@noodlecollie thanks! I merged a slightly different version that should fix the MSVC warning equally well.

lonicerae added a commit to lonicerae/uthash that referenced this pull request Sep 7, 2024
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