Repository navigation
Description
Describe the bug
[ 3%] Building CXX object src/CMakeFiles/benchmark.dir/console_reporter.cc.o
[ 9%] Building CXX object src/CMakeFiles/benchmark.dir/colorprint.cc.o
[ 9%] Building CXX object src/CMakeFiles/benchmark.dir/benchmark.cc.o
[ 12%] Building CXX object src/CMakeFiles/benchmark.dir/commandlineflags.cc.o
[ 15%] Building CXX object src/CMakeFiles/benchmark.dir/csv_reporter.cc.o
[ 18%] Building CXX object src/CMakeFiles/benchmark.dir/json_reporter.cc.o
[ 21%] Building CXX object src/CMakeFiles/benchmark.dir/log.cc.o
[ 24%] Building CXX object src/CMakeFiles/benchmark.dir/reporter.cc.o
[ 27%] Building CXX object src/CMakeFiles/benchmark.dir/sleep.cc.o
[ 30%] Building CXX object src/CMakeFiles/benchmark.dir/string_util.cc.o
[ 33%] Building CXX object src/CMakeFiles/benchmark.dir/sysinfo.cc.o
[ 36%] Building CXX object src/CMakeFiles/benchmark.dir/walltime.cc.o
[ 39%] Building CXX object src/CMakeFiles/benchmark.dir/complexity.cc.o
[ 42%] Building CXX object src/CMakeFiles/benchmark.dir/re_std.cc.o
/tmp/benchmark/src/complexity.cc:89:10: error: variable 'sigma_gn' set but not used [-Werror,-Wunused-but-set-variable]
System
uname -a
Linux playground 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux
clang --version
clang version 13.0.0 (https://github.com/llvm/llvm-project.git db45746821ab01a54f8df033991c3280c4284e3b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
To reproduce
Standard build procedure, cmake && make
Expected behavior
The library builds
Additional context
https://github.com/google/benchmark/blob/main/src/complexity.cc#L85
There probably is a subtle bug somewhere, because even though the variable is initialized (double sigma_gn = 0.0;, line 85) and serves as accumulator inside the loop (sigma_gn += gn_i;, line 93), the summed value is unused.
Activity
dmah42 commentedon Jun 8, 2021
is this a warning you're setting for your project that includes benchmark? or something that is newly defaulted to 'on' for clang 13?
I think we can just drop
sigma_gn.kpyrkosz commentedon Jun 8, 2021
This is more restrictive check for unused variables in recent clang. It is not a warning i set on for my project. The log comes from building the benchmark library itself with default options.
-Werroris hardcoded into benchmark's build script. A minimal example demonstrating the problem can be found there:https://godbolt.org/z/8nqGvMPEK
It builds with trunk gcc and clang 12. Looking at this snippet of code, this indeed is an unused variable. That's exactly the change in trunk clang that breaks the build, and new clang is definitely right there.
[NFCI] Drop warning to satisfy clang's -Wunused-but-set-variable diag
[NFCI] Drop warning to satisfy clang's -Wunused-but-set-variable diag (…
Roll benchmark to fix compile warnings in clang-13 (#7202)
[NFCI] Drop warning to satisfy clang's -Wunused-but-set-variable diag (…
enriavil1 commentedon Mar 16, 2022
Hello I am currently having the same issue on the Mac compiler. I get the following message: ".hunter/_Base/fbdd94b/ee174dc/b1b39d7/Build/benchmark/Source/src/complexity.cc:85:10: error: variable 'sigma_gn' set but not used [-Werror,-Wunused-but-set-variable]"
Update install.md
[NFCI] Drop warning to satisfy clang's -Wunused-but-set-variable diag…
[NFCI] Drop warning to satisfy clang's -Wunused-but-set-variable diag…