-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] The library does not build with clang #1172
Comments
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 |
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. 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. |
Fixes google/benchmark#1172 Also update to using state.threads()
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]" |
fix`benchmark`[1172]( google/benchmark#1172 unused `sigma_gn` variable. `git submodule update --remote` `third_party/benchmark from` `* (HEAD detached at bf585a2)` to `* (HEAD detached at e991355)`
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.The text was updated successfully, but these errors were encountered: