summaryrefslogtreecommitdiff
path: root/absl/numeric/bits_benchmark.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-10-13 14:12:39 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-10-13 14:13:57 -0700
commitf073fe8ee5dcb0aa18c893198747062f2f51ab59 (patch)
treefa473e3a4a77146484d19b456371452418e4a297 /absl/numeric/bits_benchmark.cc
parentcbaba1a9bfdc8900e0d360e87d2fee137f6f7d9e (diff)
Fix "unsafe narrowing" warnings in absl, 12/12.
Addresses failures with the following, in some files: -Wshorten-64-to-32 -Wimplicit-int-conversion -Wsign-compare -Wsign-conversion -Wtautological-unsigned-zero-compare (This specific CL enables these warnings and fixes the remaining known issues.) Bug: chromium:1292951 PiperOrigin-RevId: 480981210 Change-Id: I92d5023c6833e24d6aa29b10d433116329972f41
Diffstat (limited to 'absl/numeric/bits_benchmark.cc')
-rw-r--r--absl/numeric/bits_benchmark.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/absl/numeric/bits_benchmark.cc b/absl/numeric/bits_benchmark.cc
index b9759583..719bfa81 100644
--- a/absl/numeric/bits_benchmark.cc
+++ b/absl/numeric/bits_benchmark.cc
@@ -25,17 +25,17 @@ namespace {
template <typename T>
static void BM_bitwidth(benchmark::State& state) {
- const int count = state.range(0);
+ const auto count = static_cast<size_t>(state.range(0));
absl::BitGen rng;
std::vector<T> values;
values.reserve(count);
- for (int i = 0; i < count; ++i) {
+ for (size_t i = 0; i < count; ++i) {
values.push_back(absl::Uniform<T>(rng, 0, std::numeric_limits<T>::max()));
}
while (state.KeepRunningBatch(count)) {
- for (int i = 0; i < count; ++i) {
+ for (size_t i = 0; i < count; ++i) {
benchmark::DoNotOptimize(values[i]);
}
}
@@ -47,17 +47,17 @@ BENCHMARK_TEMPLATE(BM_bitwidth, uint64_t)->Range(1, 1 << 20);
template <typename T>
static void BM_bitwidth_nonzero(benchmark::State& state) {
- const int count = state.range(0);
+ const auto count = static_cast<size_t>(state.range(0));
absl::BitGen rng;
std::vector<T> values;
values.reserve(count);
- for (int i = 0; i < count; ++i) {
+ for (size_t i = 0; i < count; ++i) {
values.push_back(absl::Uniform<T>(rng, 1, std::numeric_limits<T>::max()));
}
while (state.KeepRunningBatch(count)) {
- for (int i = 0; i < count; ++i) {
+ for (size_t i = 0; i < count; ++i) {
const T value = values[i];
ABSL_ASSUME(value > 0);
benchmark::DoNotOptimize(value);