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

Fix signed vs unsigned comparisons #53

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

fwyzard
Copy link
Contributor

@fwyzard fwyzard commented Jan 1, 2024

Compiling with gcc 11.4 with -Werror=sign-compare fails with

detail/intrinsics.hpp:218:34: error: comparison of integer expressions of different signedness: ‘const unsigned int’ and ‘int32_t’ {aka ‘int’} [-Werror=sign-compare]
  218 |                 (src < 0 || sidx >= w) ? x : Tile::scratchpad<T>()[sidx]};
      |                             ~~~~~^~~~

@AlexVlx
Copy link
Collaborator

AlexVlx commented Feb 16, 2024

Thank you for this! Overall it looks good but a minor nit is that I'd keep uniform (unicorn) initialisation for symmetry i.e. just drop the static_cast inside the curly braces.

@fwyzard
Copy link
Contributor Author

fwyzard commented Feb 16, 2024

Do you mean

const auto sidx{static_cast<std::int32_t>((tidx / w * w) + src)};

?

Or

const std::int32_t sidx{(tidx / w * w) + src};

?

@AlexVlx
Copy link
Collaborator

AlexVlx commented Feb 16, 2024

const auto sidx{static_cast<std::int32_t>((tidx / w * w) + src)};

Preferably this please. Thank you.

Compiling with gcc 11.4 with -Werror=sign-compare fails with

detail/intrinsics.hpp:218:34: error: comparison of integer expressions of different signedness: ‘const unsigned int’ and ‘int32_t’ {aka ‘int’} [-Werror=sign-compare]
  218 |                 (src < 0 || sidx >= w) ? x : Tile::scratchpad<T>()[sidx]};
      |                             ~~~~~^~~~

Signed-off-by: Andrea Bocci <[email protected]>
@fwyzard fwyzard force-pushed the fix_signed_vs_unsiged_comparisons branch from f3343d0 to e49225b Compare February 16, 2024 13:10
@fwyzard
Copy link
Contributor Author

fwyzard commented Feb 16, 2024

Done 👍🏻

@AlexVlx AlexVlx merged commit 3fef321 into ROCm:master Feb 16, 2024
2 of 3 checks passed
@fwyzard fwyzard deleted the fix_signed_vs_unsiged_comparisons branch February 16, 2024 15:20
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.

None yet

2 participants