Skip to content

Commit

Permalink
cycleclock: Fix type conversion to match function return type
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kraj committed May 29, 2024
1 parent d77b692 commit 04cadd2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cycleclock.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() {
"sub %0, zero, %0\n"
"and %1, %1, %0\n"
: "=r"(cycles_hi0), "=r"(cycles_lo), "=r"(cycles_hi1));
return (static_cast<uint64_t>(cycles_hi1) << 32) | cycles_lo;
return static_cast<int64_t>((static_cast<uint64_t>(cycles_hi1) << 32) |
cycles_lo);
#else
uint64_t cycles;
asm volatile("rdtime %0" : "=r"(cycles));
Expand Down

0 comments on commit 04cadd2

Please sign in to comment.