Skip to content
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

Closed
kpyrkosz opened this issue Jun 5, 2021 · 3 comments · Fixed by #1174 or iree-org/iree#7202
Closed

[BUG] The library does not build with clang #1172

kpyrkosz opened this issue Jun 5, 2021 · 3 comments · Fixed by #1174 or iree-org/iree#7202
Labels
bug good first issue help wanted next-release PRs or Issues that should be included in the next release

Comments

@kpyrkosz
Copy link

kpyrkosz commented Jun 5, 2021

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.

@dmah42
Copy link
Member

dmah42 commented 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.

@dmah42 dmah42 added bug good first issue help wanted next-release PRs or Issues that should be included in the next release labels Jun 8, 2021
@kpyrkosz
Copy link
Author

kpyrkosz commented 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. -Werror is 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.

@enriavil1
Copy link

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]"

anigkus added a commit to anigkus/RedisDesktopManager that referenced this issue Jun 2, 2022
  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)`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue help wanted next-release PRs or Issues that should be included in the next release
Projects
None yet
3 participants