precice / aste

Artificial Solver Testing Environment
GNU General Public License v3.0
10 stars 11 forks source link

Compiler warnings #146

Closed MakisH closed 1 year ago

MakisH commented 1 year ago

Globally on my environment, I set CXXFLAGS to -Wall -Wextra -Wno-unused-parameter. This often reveals interesting warnings. In the case of aste:

~/github/aste/build [develop]$ make
[  6%] Building CXX object CMakeFiles/metisAPI.dir/src/metisAPI.cpp.o
/home/makish/github/aste/src/metisAPI.cpp: In function ‘void partitionMetis(idx_t, idx_t, idx_t*, idx_t*, idx_t, idx_t*)’:
/home/makish/github/aste/src/metisAPI.cpp:13:22: warning: unused variable ‘result’ [-Wunused-variable]
   13 |   int                result = METIS_PartMeshNodal(&cell_count, &point_count, cellptr, celldata, 0, 0, &nparts, 0, options, &objval, cell_partition.data(), point_partition);
      |                      ^~~~~~
[ 12%] Linking CXX shared library libmetisAPI.so
[ 12%] Built target metisAPI
[ 18%] Building CXX object CMakeFiles/precice-aste-run.dir/src/precice-aste-run.cpp.o
[ 25%] Building CXX object CMakeFiles/precice-aste-run.dir/src/common.cpp.o
[ 31%] Building CXX object CMakeFiles/precice-aste-run.dir/src/mesh.cpp.o
/home/makish/github/aste/src/mesh.cpp: In member function ‘void aste::MeshName::save(const aste::Mesh&, const string&) const’:
/home/makish/github/aste/src/mesh.cpp:324:26: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘vtkIdType’ {aka ‘long long int’} [-Wsign-compare]
  324 |     for (size_t i = 0; i < grid->GetNumberOfPoints(); i++) {
      |                        ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 37%] Building CXX object CMakeFiles/precice-aste-run.dir/src/configreader.cpp.o
/home/makish/github/aste/src/configreader.cpp: In member function ‘void aste::asteConfig::load(const string&)’:
/home/makish/github/aste/src/configreader.cpp:12:30: warning: catching polymorphic type ‘class nlohmann::detail::parse_error’ by value [-Wcatch-value=]
   12 |   } catch (nlohmann::detail::parse_error) {
      |                              ^~~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:15:30: warning: catching polymorphic type ‘class nlohmann::detail::type_error’ by value [-Wcatch-value=]
   15 |   } catch (nlohmann::detail::type_error) {
      |                              ^~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:22:30: warning: catching polymorphic type ‘class nlohmann::detail::parse_error’ by value [-Wcatch-value=]
   22 |   } catch (nlohmann::detail::parse_error) {
      |                              ^~~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:25:30: warning: catching polymorphic type ‘class nlohmann::detail::type_error’ by value [-Wcatch-value=]
   25 |   } catch (nlohmann::detail::type_error) {
      |                              ^~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:32:30: warning: catching polymorphic type ‘class nlohmann::detail::type_error’ by value [-Wcatch-value=]
   32 |   } catch (nlohmann::detail::type_error) {
      |                              ^~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:35:32: warning: catching polymorphic type ‘class nlohmann::detail::type_error’ by value [-Wcatch-value=]
   35 |     } catch (nlohmann::detail::type_error) {
      |                                ^~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:38:19: warning: catching polymorphic type ‘class std::invalid_argument’ by value [-Wcatch-value=]
   38 |     } catch (std::invalid_argument) {
      |                   ^~~~~~~~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:60:32: warning: catching polymorphic type ‘class nlohmann::detail::parse_error’ by value [-Wcatch-value=]
   60 |     } catch (nlohmann::detail::parse_error) {
      |                                ^~~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:63:32: warning: catching polymorphic type ‘class nlohmann::detail::type_error’ by value [-Wcatch-value=]
   63 |     } catch (nlohmann::detail::type_error) {
      |                                ^~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:70:32: warning: catching polymorphic type ‘class nlohmann::detail::parse_error’ by value [-Wcatch-value=]
   70 |     } catch (nlohmann::detail::parse_error) {
      |                                ^~~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:73:32: warning: catching polymorphic type ‘class nlohmann::detail::type_error’ by value [-Wcatch-value=]
   73 |     } catch (nlohmann::detail::type_error) {
      |                                ^~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:83:24: warning: comparison of integer expressions of different signedness: ‘int’ and ‘const long unsigned int’ [-Wsign-compare]
   83 |     for (auto k = 0; k < readScalarSize; k++) {
      |                      ~~^~~~~~~~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:87:24: warning: comparison of integer expressions of different signedness: ‘int’ and ‘const long unsigned int’ [-Wsign-compare]
   87 |     for (auto k = 0; k < readVectorSize; k++) {
      |                      ~~^~~~~~~~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:91:24: warning: comparison of integer expressions of different signedness: ‘int’ and ‘const long unsigned int’ [-Wsign-compare]
   91 |     for (auto k = 0; k < writeScalarSize; k++) {
      |                      ~~^~~~~~~~~~~~~~~~~
/home/makish/github/aste/src/configreader.cpp:95:24: warning: comparison of integer expressions of different signedness: ‘int’ and ‘const long unsigned int’ [-Wsign-compare]
   95 |     for (auto k = 0; k < writeVectorSize; k++) {
      |                      ~~^~~~~~~~~~~~~~~~~
[ 43%] Building CXX object CMakeFiles/precice-aste-run.dir/src/modes.cpp.o
/home/makish/github/aste/src/modes.cpp: In function ‘void aste::runReplayMode(const aste::ExecutionContext&, const string&)’:
/home/makish/github/aste/src/modes.cpp:116:56: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
  116 |   while (preciceInterface.isCouplingOngoing() && round < minMeshSize) {
      |                                                  ~~~~~~^~~~~~~~~~~~~
[ 50%] Building CXX object CMakeFiles/precice-aste-run.dir/src/utilities.cpp.o
In file included from /usr/include/c++/11/cassert:44,
                 from /home/makish/github/aste/src/modes.hpp:3,
                 from /home/makish/github/aste/src/utilities.hpp:21,
                 from /home/makish/github/aste/src/utilities.cpp:1:
/home/makish/github/aste/src/utilities.cpp: In function ‘std::vector<int, std::allocator<int> > aste::setupVertexIDs(precice::SolverInterface&, const aste::Mesh&, int)’:
/home/makish/github/aste/src/utilities.cpp:44:23: warning: comparison of integer expressions of different signedness: ‘std::vector<double>::size_type’ {aka ‘long unsigned int’} and ‘const int’ [-Wsign-compare]
   44 |     assert(pos.size() == dimension);
      |            ~~~~~~~~~~~^~~~~~~~~~~~
[ 56%] Building CXX object CMakeFiles/precice-aste-run.dir/src/logger.cpp.o
[ 62%] Linking CXX executable precice-aste-run
[ 62%] Built target precice-aste-run
[ 68%] Building CXX object CMakeFiles/testing.dir/tests/testing.cpp.o
[ 75%] Building CXX object CMakeFiles/testing.dir/tests/read_test.cpp.o
[ 81%] Building CXX object CMakeFiles/testing.dir/tests/write_test.cpp.o
[ 87%] Building CXX object CMakeFiles/testing.dir/src/mesh.cpp.o
/home/makish/github/aste/src/mesh.cpp: In member function ‘void aste::MeshName::save(const aste::Mesh&, const string&) const’:
/home/makish/github/aste/src/mesh.cpp:324:26: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘vtkIdType’ {aka ‘long long int’} [-Wsign-compare]
  324 |     for (size_t i = 0; i < grid->GetNumberOfPoints(); i++) {
      |                        ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 93%] Building CXX object CMakeFiles/testing.dir/src/logger.cpp.o
[100%] Linking CXX executable testing
[100%] Built target testing