Code Monkey home page Code Monkey logo

Comments (4)

dmah42 avatar dmah42 commented on May 27, 2024

I don't have a 32-bit or iOS build to test against. Could you drop a log of the errors into this issue please?

from benchmark.

mrdomino avatar mrdomino commented on May 27, 2024

It turns out to be sufficient to add -Wshorten-64-to-32 to the compilation flags, at least on my system:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 480d8a5..d46c0dd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,6 +33,7 @@ endif()

 # Turn compiler warnings up to 11
 include(AddCXXCompilerFlag)
+add_cxx_compiler_flag(-Wshorten-64-to-32)
 add_cxx_compiler_flag(-Wall)
 add_cxx_compiler_flag(-Wshadow)
 add_cxx_compiler_flag(-Werror)

The resulting warnings (treated as errors):

[ 50%] Building CXX object src/CMakeFiles/benchmark.dir/benchmark.cc.o
In file included from /usr/local/src/benchmark/src/benchmark.cc:15:
/usr/local/src/benchmark/include/benchmark/benchmark.h:230:35: error: implicit conversion loses integer precision: 'const int64_t' (aka 'const long long') to 'int' [-Werror,-Wshorten-64-to-32]
  int iterations() const { return total_iterations_; }
                           ~~~~~~ ^~~~~~~~~~~~~~~~~
/usr/local/src/benchmark/src/benchmark.cc:119:23: error: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Werror,-Wshorten-64-to-32]
        *exponent = i + 1;
                  ~ ~~^~~
/usr/local/src/benchmark/src/benchmark.cc:133:24: error: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Werror,-Wshorten-64-to-32]
        *exponent = -i - 1;
                  ~ ~~~^~~
/usr/local/src/benchmark/src/benchmark.cc:351:14: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
      return index;
      ~~~~~~ ^~~~~
/usr/local/src/benchmark/src/benchmark.cc:354:15: error: implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  int index = families_.size();
      ~~~~~   ^~~~~~~~~~~~~~~~
/usr/local/src/benchmark/src/benchmark.cc:397:54: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
        instances = family->CreateBenchmarkInstances(x, Benchmark::kNoRange);
                    ~~~~~~                           ^
/usr/local/src/benchmark/src/benchmark.cc:404:56: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
          instances = family->CreateBenchmarkInstances(x, y);
                      ~~~~~~                           ^
/usr/local/src/benchmark/src/benchmark.cc:404:59: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
          instances = family->CreateBenchmarkInstances(x, y);
                      ~~~~~~                              ^
/usr/local/src/benchmark/src/benchmark.cc:1239:65: error: implicit conversion loses integer precision: 'unsigned long' to 'const int' [-Werror,-Wshorten-64-to-32]
          std::max<int>(name_field_width, benchmark.name.size() + 17);
          ~~~                             ~~~~~~~~~~~~~~~~~~~~~~^~~~
/usr/local/src/benchmark/src/benchmark.cc:1242:65: error: implicit conversion loses integer precision: 'unsigned long' to 'const int' [-Werror,-Wshorten-64-to-32]
          std::max<int>(name_field_width, benchmark.name.size() + 10);
          ~~~                             ~~~~~~~~~~~~~~~~~~~~~~^~~~
/usr/local/src/benchmark/src/benchmark.cc:1245:65: error: implicit conversion loses integer precision: 'unsigned long' to 'const int' [-Werror,-Wshorten-64-to-32]
          std::max<int>(name_field_width, benchmark.name.size() + 7);
          ~~~                             ~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/local/src/benchmark/src/benchmark.cc:1247:58: error: implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'const int' [-Werror,-Wshorten-64-to-32]
      name_field_width = std::max<int>(name_field_width, benchmark.name.size());
                         ~~~                             ^~~~~~~~~~~~~~~~~~~~~
12 errors generated.
make[2]: *** [src/CMakeFiles/benchmark.dir/benchmark.cc.o] Error 1

from benchmark.

mrdomino avatar mrdomino commented on May 27, 2024

Thanks!

from benchmark.

mrdomino avatar mrdomino commented on May 27, 2024

Actually, there's one more:

../../3rdparty/benchmark/src/sleep.cc:30:36: error: implicit conversion loses integer precision: 'long long' to '__darwin_time_t' (aka 'long') [-Werror,-Wshorten-64-to-32]
  sleep_time.tv_sec = microseconds / kNumMicrosPerSecond;
                    ~ ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

from benchmark.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.