Skip to content

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

Closed
iree-org/iree
#7202

Description

@kpyrkosz

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

  1. dmah42 commented on Jun 8, 2021

    @dmah42
    Member

    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.

  2. added
    next-release
    on Jun 8, 2021
  3. kpyrkosz commented on Jun 8, 2021

    @kpyrkosz
    Author

    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.

  4. enriavil1 commented on Mar 16, 2022

    @enriavil1

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

  5. added a commit that references this issue on Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issuehelp wantednext-release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions