google / benchmark

A microbenchmark support library
Apache License 2.0
8.59k stars 1.57k forks source link

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

Closed kraj closed 1 month ago

kraj commented 1 month ago

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(cycles_hi1) << 32) | cycles_lo; | ~~ ~~~~~~~~^~~~~ 1 error generated.

kraj commented 1 month ago

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

thats right.

LebedevRI commented 1 month ago

Looks like clang-format isn't happy

kraj commented 1 month ago

Looks like clang-format isn't happy

yeah. Fixed in v3, hopefully

LebedevRI commented 1 month ago

@kraj thank you for the contribution!