Skip to content

[OpenMP][NFC] Fix -Wsign-compare warning in kmp_collapse.cpp #137487

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 1 commit into
base: main
Choose a base branch
from

Conversation

ReVe1uv
Copy link
Contributor

@ReVe1uv ReVe1uv commented Apr 27, 2025

Fix a signed/unsigned comparison warning in kmp_collapse.cpp.

inner_ub0_u64 is of type kmp_uint64, but was being compared against -1, a signed integer literal, triggering a -Wsign-compare warning.

This patch explicitly casts -1 to (kmp_uint64)-1 to avoid the warning and ensure correct comparison behavior.

llvm-project/openmp/runtime/src/kmp_collapse.cpp:1317:44: warning: comparison of integer expressions of different signedness: ‘kmp_uint64’ {aka ‘long long unsigned int’} and ‘int’ [-Wsign-compare]
 1317 |       (inner_ub0_u64 == 0 || inner_ub0_u64 == -1) && inner_ub1_u64 == 1) {

@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label Apr 27, 2025
Copy link

github-actions bot commented Apr 27, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Fix a signed/unsigned comparison warning in `kmp_collapse.cpp`.

`inner_ub0_u64` is of type `kmp_uint64`, but was being compared against `-1`,
a signed integer literal, triggering a `-Wsign-compare` warning.

This patch explicitly casts `-1` to `(kmp_uint64)-1` to avoid the warning
and ensure correct comparison behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openmp:libomp OpenMP host runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants