Closed Arech closed 8 months ago
Describe the bug There are some trivial compilation errors due -Werror and old-style C-casts in QNX specific block of src/sysinfo.cc
-Werror
src/sysinfo.cc
FAILED: src/CMakeFiles/benchmark.dir/sysinfo.cc.o qnx-sdp/qnx710/host/linux/x86_64/usr/bin/ntoaarch64-g++ --sysroot=qnx-sdp/qnx710/target/qnx7 -DBENCHMARK_STATIC_DEFINE -DHAVE_STD_REGEX -DHAVE_STEADY_CLOCK -D_QNX_SOURCE -I/home/user/vcpkg/buildtrees/benchmark/src/v1.8.3-eb6e61b079.clean/include -I/home/user/vcpkg/buildtrees/benchmark/src/v1.8.3-eb6e61b079.clean/src -fexceptions -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L -D_QNX_SOURCE -fexceptions -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L -D_QNX_SOURCE -Wall -Wextra -Wshadow -Wfloat-equal -Wold-style-cast -Werror -Wsuggest-override -pedantic -pedantic-errors -fstrict-aliasing -Wno-deprecated-declarations -Wno-deprecated -Wstrict-aliasing -g -std=c++11 -fvisibility=hidden -fvisibility-inlines-hidden -MD -MT src/CMakeFiles/benchmark.dir/sysinfo.cc.o -MF src/CMakeFiles/benchmark.dir/sysinfo.cc.o.d -o src/CMakeFiles/benchmark.dir/sysinfo.cc.o -c /home/user/vcpkg/buildtrees/benchmark/src/v1.8.3-eb6e61b079.clean/src/sysinfo.cc /home/user/vcpkg/buildtrees/benchmark/src/v1.8.3-eb6e61b079.clean/src/sysinfo.cc: In function 'double benchmark::{anonymous}::GetCPUCyclesPerSecond(benchmark::CPUInfo::Scaling)': /home/user/vcpkg/buildtrees/benchmark/src/v1.8.3-eb6e61b079.clean/src/sysinfo.cc:774:69: error: use of old-style cast to 'int64_t' {aka 'long int'} [-Werror=old-style-cast] return static_cast<double>((int64_t)(SYSPAGE_ENTRY(cpuinfo)->speed) * ^ --------- static_cast<int64_t> ( ) /home/user/vcpkg/buildtrees/benchmark/src/v1.8.3-eb6e61b079.clean/src/sysinfo.cc:775:51: error: use of old-style cast to 'int64_t' {aka 'long int'} [-Werror=old-style-cast] (int64_t)(1000 * 1000)); ^ --------- static_cast<int64_t> () cc1plus: all warnings being treated as errors
Patch suggestion
diff --git a/src/sysinfo.cc b/src/sysinfo.cc index 922e83a..ec9fd35 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -771,8 +771,8 @@ double GetCPUCyclesPerSecond(CPUInfo::Scaling scaling) { kstat_close(kc); return clock_hz; #elif defined(BENCHMARK_OS_QNX) - return static_cast<double>((int64_t)(SYSPAGE_ENTRY(cpuinfo)->speed) * - (int64_t)(1000 * 1000)); + return static_cast<double>(static_cast<int64_t>(SYSPAGE_ENTRY(cpuinfo)->speed) * + static_cast<int64_t>(1000 * 1000)); #elif defined(BENCHMARK_OS_QURT) // QuRT doesn't provide any API to query Hexagon frequency. return 1000000000;
@Arech do you feel like submitting it as a pull request? :)
@LebedevRI will do within about week, ok? Need to finish with some important work stuff first.
Describe the bug There are some trivial compilation errors due
-Werror
and old-style C-casts in QNX specific block ofsrc/sysinfo.cc
Patch suggestion