Skip to content

Commit 3ed6810

Browse files
authored
Fix MicroBenchmark build on Linux with clang 18.1.8 (#141)
MicroBenchmarks/libs/benchmark/test/options_test.cc fails to build on Linux/AArch64 with following error: error: variable 'actual_iterations' set but not used This patch adds benchmark::DoNotOptimize(actual_iterations); to to function BM_explicit_iteration_count in options_test.cc -Wall and -Werror were being used to compile and I am surprised that this was not caught by any of the buildbots. Some versions of clang compile this all fine with -Wall -Werror.
1 parent 9cb6215 commit 3ed6810

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

MicroBenchmarks/libs/benchmark/test/options_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ void BM_explicit_iteration_count(benchmark::State& state) {
6767
assert(state.max_iterations == 42);
6868
size_t actual_iterations = 0;
6969
for (auto _ : state) ++actual_iterations;
70+
benchmark::DoNotOptimize(actual_iterations);
71+
assert(actual_iterations == 42);
7072
assert(state.iterations() == state.max_iterations);
7173
assert(state.iterations() == 42);
7274
}

0 commit comments

Comments
 (0)