diff options
author | Martin Ankerl <martin.ankerl@gmail.com> | 2021-09-18 14:12:43 +0200 |
---|---|---|
committer | Martin Ankerl <martin.ankerl@gmail.com> | 2021-09-21 14:45:49 +0200 |
commit | e148a5233292d156cda76cb20afb6641fc20f25e (patch) | |
tree | a51d7fe8c61d86c1254d443e78b5dc31fd4d2d88 /src/bench/rollingbloom.cpp | |
parent | da4e2f1da0388d424659fa8c853fcaf37b4b5959 (diff) |
bench: fixed ubsan implicit conversion
The benchmarks can now run much longer due to the minimum of 10ms or
directly with -min_time. With -min_time=20000 I could trigger two ubsan
errors in the benchmarks, which are fixed in this commit by using
unsigned type and adding "& 0xFF".
Diffstat (limited to 'src/bench/rollingbloom.cpp')
-rw-r--r-- | src/bench/rollingbloom.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/bench/rollingbloom.cpp b/src/bench/rollingbloom.cpp index 997ab56549..28167767db 100644 --- a/src/bench/rollingbloom.cpp +++ b/src/bench/rollingbloom.cpp @@ -13,16 +13,16 @@ static void RollingBloom(benchmark::Bench& bench) uint32_t count = 0; bench.run([&] { count++; - data[0] = count; - data[1] = count >> 8; - data[2] = count >> 16; - data[3] = count >> 24; + data[0] = count & 0xFF; + data[1] = (count >> 8) & 0xFF; + data[2] = (count >> 16) & 0xFF; + data[3] = (count >> 24) & 0xFF; filter.insert(data); - data[0] = count >> 24; - data[1] = count >> 16; - data[2] = count >> 8; - data[3] = count; + data[0] = (count >> 24) & 0xFF; + data[1] = (count >> 16) & 0xFF; + data[2] = (count >> 8) & 0xFF; + data[3] = count & 0xFF; filter.contains(data); }); } |