remove old-style (C-style) casts (#1614)

Remove old-style (C-style) casts

This is required by the Google C++ style guide:
https://google.github.io/styleguide/cppguide.html#Casting
This commit is contained in:
Gary Miguel 2023-06-21 15:35:44 -07:00 committed by GitHub
parent b323288cba
commit 1d25c2e3be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 2 deletions

View File

@ -49,6 +49,10 @@ cc_library(
":windows": ["-DEFAULTLIB:shlwapi.lib"],
"//conditions:default": ["-pthread"],
}),
copts = select({
":windows": [],
"//conditions:default": ["-Werror=old-style-cast"],
}),
strip_include_prefix = "include",
visibility = ["//visibility:public"],
# Only static linking is allowed; no .so will be produced.

View File

@ -175,6 +175,7 @@ else()
add_cxx_compiler_flag(-Wextra)
add_cxx_compiler_flag(-Wshadow)
add_cxx_compiler_flag(-Wfloat-equal)
add_cxx_compiler_flag(-Wold-style-cast)
if(BENCHMARK_ENABLE_WERROR)
add_cxx_compiler_flag(-Werror)
endif()

View File

@ -229,7 +229,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(std::fpclassify((double)counters[name]), FP_ZERO);
BM_CHECK_EQ(std::fpclassify(double{counters[name]}), FP_ZERO);
counters[name] = Counter(measurement, Counter::kAvgIterations);
}
}

View File

@ -61,7 +61,7 @@ inline int& LogLevel() {
}
inline LogType& GetNullLogInstance() {
static LogType null_log((std::ostream*)nullptr);
static LogType null_log(static_cast<std::ostream*>(nullptr));
return null_log;
}