diff --git a/CMakeLists.txt b/CMakeLists.txt index cc80702c..6880c1f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,6 +181,7 @@ else() add_cxx_compiler_flag(-Wall) add_cxx_compiler_flag(-Wextra) add_cxx_compiler_flag(-Wshadow) + add_cxx_compiler_flag(-Wfloat-equal) if(BENCHMARK_ENABLE_WERROR) add_cxx_compiler_flag(-Werror RELEASE) add_cxx_compiler_flag(-Werror RELWITHDEBINFO) diff --git a/src/benchmark.cc b/src/benchmark.cc index eb7f6566..d2306881 100644 --- a/src/benchmark.cc +++ b/src/benchmark.cc @@ -195,7 +195,7 @@ void State::PauseTiming() { for (const auto& name_and_measurement : measurements) { auto name = name_and_measurement.first; auto measurement = name_and_measurement.second; - BM_CHECK_EQ(counters[name], 0.0); + BM_CHECK_EQ(std::fpclassify((double)counters[name]), FP_ZERO); counters[name] = Counter(measurement, Counter::kAvgIterations); } }