Thanks to visit codestin.com
Credit goes to github.com

Skip to content

cycleclock: Fix type conversion to match function return type #1794

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

Merged
merged 1 commit into from
May 29, 2024

Conversation

kraj
Copy link
Contributor

@kraj kraj commented May 29, 2024

fixes build with clang19

src/cycleclock.h:208:52: error: implicit conversion changes signedness: 'uint64_t' (aka 'unsigned long long') to 'int64_t' (aka 'long long') [-Werror,-Wsign-conversion]
208 | return (static_cast<uint64_t>(cycles_hi1) << 32) | cycles_lo;
| ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
1 error generated.

Copy link
Collaborator

@LebedevRI LebedevRI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast should be on the outside,
shifting signed values is generally not recommended.

@kraj
Copy link
Contributor Author

kraj commented May 29, 2024

The cast should be on the outside, shifting signed values is generally not recommended.

thats right.

LebedevRI
LebedevRI previously approved these changes May 29, 2024
@LebedevRI
Copy link
Collaborator

Looks like clang-format isn't happy

@LebedevRI LebedevRI self-requested a review May 29, 2024 03:04
fixes build with clang19

src/cycleclock.h:208:52: error: implicit conversion changes signedness: 'uint64_t' (aka 'unsigned long long') to 'int64_t' (aka 'long long') [-Werror,-Wsign-conversion]
  208 |   return (static_cast<uint64_t>(cycles_hi1) << 32) | cycles_lo;
      |   ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
1 error generated.
@kraj
Copy link
Contributor Author

kraj commented May 29, 2024

Looks like clang-format isn't happy

yeah. Fixed in v3, hopefully

@LebedevRI LebedevRI merged commit 7f0e99a into google:main May 29, 2024
80 checks passed
@LebedevRI
Copy link
Collaborator

@kraj thank you for the contribution!

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