graphgrove icon indicating copy to clipboard operation
graphgrove copied to clipboard

[Build]: 79 warnings when building graphgrove

Open crazoter opened this issue 2 years ago • 0 comments

Context When building graphgrove, there are numerous warnings indicating poor code quality for some of the components in the codebase. Some of these warnings are superfluous, but they do sometimes indicate a potential bug (e.g. due to inappropriate use of a variable, using the wrong variable, or unexpected behavior arising from inappropriate variable comparison)

Below is an excerpt of the build logs that contain the warnings:

x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ilib/ -I/usr/include/python3.10 -I/usr/local/lib/python3.10/dist-packages/numpy/core/include -c src/sg_tree/sg_tree.cpp -o build/temp.linux-x86_64-cpython-310/src/sg_tree/sg_tree.o -march=corei7-avx -pthread -std=c++14
src/sg_tree/sg_tree.cpp: In member function ‘std::vector<unsigned int> SGTree::getBestInitialPoints(unsigned int) const’:
src/sg_tree/sg_tree.cpp:1014:14: warning: variable ‘childLeft’ set but not used [-Wunused-but-set-variable]
 1014 |         bool childLeft = false;
      |              ^~~~~~~~~
In file included from src/sg_tree/sg_tree.h:32,
                 from src/sg_tree/sg_tree.cpp:18:
src/sg_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = SGTree::SGTree(const Eigen::Map<Eigen::Matrix<float, -1, -1> >&, int, unsigned int)::<lambda(size_t)>; size_t = long unsigned int]’:
src/sg_tree/sg_tree.cpp:829:44:   required from here
src/sg_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
   80 |         if (cores == -1) {
      |             ~~~~~~^~~~~
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ilib/ -I/usr/include/python3.10 -I/usr/local/lib/python3.10/dist-packages/numpy/core/include -c src/sg_tree/sgtreecmodule.cxx -o build/temp.linux-x86_64-cpython-310/src/sg_tree/sgtreecmodule.o -march=corei7-avx -pthread -std=c++14
src/sg_tree/sgtreecmodule.cxx:543:31: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
  543 |   if (!PyArg_ParseTuple(args, "nO!"PYTHON_FLOAT_CHAR"lp:sgtreec_range", &int_ptr, &PyArray_Type, &in_array, &r, &cores, &return_points))
      |                               ^
src/sg_tree/sgtreecmodule.cxx: In function ‘PyObject* sgtreec_knn(PyObject*, PyObject*)’:
src/sg_tree/sgtreecmodule.cxx:315:11: warning: unused variable ‘results’ [-Wunused-variable]
  315 |   scalar *results = nullptr;
      |           ^~~~~~~
src/sg_tree/sgtreecmodule.cxx: In function ‘PyObject* sgtreec_knn_beam(PyObject*, PyObject*)’:
src/sg_tree/sgtreecmodule.cxx:444:11: warning: unused variable ‘results’ [-Wunused-variable]
  444 |   scalar *results = nullptr;
      |           ^~~~~~~
In file included from src/sg_tree/sg_tree.h:32,
                 from src/sg_tree/sgtreecmodule.cxx:22:
src/sg_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = sgtreec_batchinsert(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/sg_tree/sgtreecmodule.cxx:126:38:   required from here
src/sg_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
   80 |         if (cores == -1) {
      |             ~~~~~~^~~~~
src/sg_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = sgtreec_nn(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/sg_tree/sgtreecmodule.cxx:200:40:   required from here
src/sg_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
src/sg_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = sgtreec_nn(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/sg_tree/sgtreecmodule.cxx:239:40:   required from here
src/sg_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
src/sg_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = sgtreec_knn(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/sg_tree/sgtreecmodule.cxx:327:40:   required from here
src/sg_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
src/sg_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = sgtreec_knn(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/sg_tree/sgtreecmodule.cxx:364:40:   required from here
src/sg_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
src/sg_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = sgtreec_knn_beam(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/sg_tree/sgtreecmodule.cxx:456:40:   required from here
src/sg_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
src/sg_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = sgtreec_knn_beam(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/sg_tree/sgtreecmodule.cxx:493:40:   required from here
src/sg_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
src/sg_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = sgtreec_range(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/sg_tree/sgtreecmodule.cxx:570:40:   required from here
src/sg_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
src/sg_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = sgtreec_range(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/sg_tree/sgtreecmodule.cxx:641:40:   required from here
src/sg_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ilib/ -I/usr/include/python3.10 -I/usr/local/lib/python3.10/dist-packages/numpy/core/include -c src/sg_tree/utils.cpp -o build/temp.linux-x86_64-cpython-310/src/sg_tree/utils.o -march=corei7-avx -pthread -std=c++14
x86_64-linux-gnu-g++ -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 build/temp.linux-x86_64-cpython-310/src/sg_tree/sg_tree.o build/temp.linux-x86_64-cpython-310/src/sg_tree/sgtreecmodule.o build/temp.linux-x86_64-cpython-310/src/sg_tree/utils.o -L/usr/lib/x86_64-linux-gnu -o build/lib.linux-x86_64-cpython-310/sgtreec.cpython-310-x86_64-linux-gnu.so -march=corei7-avx -pthread -std=c++14
building 'covertreec' extension
creating build/temp.linux-x86_64-cpython-310/src/cover_tree
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ilib/ -I/usr/include/python3.10 -I/usr/local/lib/python3.10/dist-packages/numpy/core/include -c src/cover_tree/cover_tree.cpp -o build/temp.linux-x86_64-cpython-310/src/cover_tree/cover_tree.o -march=corei7-avx -pthread -std=c++14
src/cover_tree/cover_tree.cpp: In member function ‘std::vector<unsigned int> CoverTree::getBestInitialPoints(unsigned int) const’:
src/cover_tree/cover_tree.cpp:950:14: warning: variable ‘childLeft’ set but not used [-Wunused-but-set-variable]
  950 |         bool childLeft = false;
      |              ^~~~~~~~~
In file included from src/cover_tree/cover_tree.h:33,
                 from src/cover_tree/cover_tree.cpp:18:
src/cover_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = CoverTree::CoverTree(const Eigen::Map<Eigen::Matrix<float, -1, -1> >&, int, unsigned int)::<lambda(size_t)>; size_t = long unsigned int]’:
src/cover_tree/cover_tree.cpp:716:44:   required from here
src/cover_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
   80 |         if (cores == -1) {
      |             ~~~~~~^~~~~
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ilib/ -I/usr/include/python3.10 -I/usr/local/lib/python3.10/dist-packages/numpy/core/include -c src/cover_tree/covertreecmodule.cxx -o build/temp.linux-x86_64-cpython-310/src/cover_tree/covertreecmodule.o -march=corei7-avx -pthread -std=c++14
src/cover_tree/covertreecmodule.cxx:418:31: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
  418 |   if (!PyArg_ParseTuple(args, "nO!"PYTHON_FLOAT_CHAR"lp:covertreec_range", &int_ptr, &PyArray_Type, &in_array, &r, &cores, &return_points))
      |                               ^
src/cover_tree/covertreecmodule.cxx: In function ‘PyObject* covertreec_nn(PyObject*, PyObject*)’:
src/cover_tree/covertreecmodule.cxx:203:11: warning: variable ‘results’ set but not used [-Wunused-but-set-variable]
  203 |   scalar *results = nullptr;
      |           ^~~~~~~
src/cover_tree/covertreecmodule.cxx: In function ‘PyObject* covertreec_knn(PyObject*, PyObject*)’:
src/cover_tree/covertreecmodule.cxx:319:11: warning: unused variable ‘results’ [-Wunused-variable]
  319 |   scalar *results = nullptr;
      |           ^~~~~~~
In file included from src/cover_tree/cover_tree.h:33,
                 from src/cover_tree/covertreecmodule.cxx:22:
src/cover_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = covertreec_batchinsert(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/cover_tree/covertreecmodule.cxx:126:38:   required from here
src/cover_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
   80 |         if (cores == -1) {
      |             ~~~~~~^~~~~
src/cover_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = covertreec_nn(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/cover_tree/covertreecmodule.cxx:216:40:   required from here
src/cover_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
src/cover_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = covertreec_nn(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/cover_tree/covertreecmodule.cxx:246:40:   required from here
src/cover_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
src/cover_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = covertreec_knn(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/cover_tree/covertreecmodule.cxx:331:40:   required from here
src/cover_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
src/cover_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = covertreec_knn(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/cover_tree/covertreecmodule.cxx:368:40:   required from here
src/cover_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
src/cover_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = covertreec_range(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/cover_tree/covertreecmodule.cxx:445:40:   required from here
src/cover_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
src/cover_tree/utils.h: In instantiation of ‘UnaryFunction utils::parallel_for_progressbar(size_t, size_t, UnaryFunction, unsigned int) [with UnaryFunction = covertreec_range(PyObject*, PyObject*)::<lambda(npy_intp)>; size_t = long unsigned int]’:
src/cover_tree/covertreecmodule.cxx:516:40:   required from here
src/cover_tree/utils.h:80:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ilib/ -I/usr/include/python3.10 -I/usr/local/lib/python3.10/dist-packages/numpy/core/include -c src/cover_tree/utils.cpp -o build/temp.linux-x86_64-cpython-310/src/cover_tree/utils.o -march=corei7-avx -pthread -std=c++14
x86_64-linux-gnu-g++ -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 build/temp.linux-x86_64-cpython-310/src/cover_tree/cover_tree.o build/temp.linux-x86_64-cpython-310/src/cover_tree/covertreecmodule.o build/temp.linux-x86_64-cpython-310/src/cover_tree/utils.o -L/usr/lib/x86_64-linux-gnu -o build/lib.linux-x86_64-cpython-310/covertreec.cpython-310-x86_64-linux-gnu.so -march=corei7-avx -pthread -std=c++14
building 'sccc' extension
creating build/temp.linux-x86_64-cpython-310/src/scc
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ilib/ -I/usr/include/python3.10 -I/usr/local/lib/python3.10/dist-packages/numpy/core/include -c src/scc/scc.cpp -o build/temp.linux-x86_64-cpython-310/src/scc/scc.o -march=corei7-avx -pthread -std=c++14
src/scc/scc.cpp: In lambda function:
src/scc/scc.cpp:274:19: warning: unused variable ‘k’ [-Wunused-variable]
  274 |         node_id_t k = u_node->this_id;
      |                   ^
src/scc/scc.cpp: In static member function ‘static bool SCC::TreeLevel::update_levels(SCC::TreeLevel*, scalar, SCC::TreeLevel*)’:
src/scc/scc.cpp:1603:12: warning: unused variable ‘vector_update’ [-Wunused-variable]
 1603 |     scalar vector_update = 0.0f;
      |            ^~~~~~~~~~~~~
src/scc/scc.cpp: In member function ‘bool SCC::add_graph_edges_mb(std::vector<unsigned int>&, std::vector<unsigned int>&, std::vector<float>&)’:
src/scc/scc.cpp:2345:16: warning: variable ‘num_pts’ set but not used [-Wunused-but-set-variable]
 2345 |         size_t num_pts = levels[0]->nodes.size();
      |                ^~~~~~~
src/scc/scc.cpp: In member function ‘bool SCC::fit_on_graph()’:
src/scc/scc.cpp:2409:16: warning: unused variable ‘round0’ [-Wunused-variable]
 2409 |     TreeLevel *round0 = levels[0];
      |                ^~~~~~
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ilib/ -I/usr/include/python3.10 -I/usr/local/lib/python3.10/dist-packages/numpy/core/include -c src/scc/scccmodule.cxx -o build/temp.linux-x86_64-cpython-310/src/scc/scccmodule.o -march=corei7-avx -pthread -std=c++14
src/scc/scccmodule.cxx: In function ‘PyObject* sccc_node_descendants(PyObject*, PyObject*)’:
src/scc/scccmodule.cxx:525:32: warning: narrowing conversion of ‘desc.std::set<unsigned int>::size()’ from ‘std::set<unsigned int>::size_type’ {aka ‘long unsigned int’} to ‘npy_intp’ {aka ‘long int’} [-Wnarrowing]
  525 |   npy_intp dims[2] = {desc.size(), 1};
      |                       ~~~~~~~~~^~
In file included from src/scc/scc.h:45,
                 from src/scc/scccmodule.cxx:24:
src/scc/utils.h: At global scope:
src/scc/utils.h:72:17: warning: ‘long int utils::timedur_long(std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >, std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >)’ defined but not used [-Wunused-function]
   72 |     static long timedur_long(std::chrono::time_point<std::chrono::high_resolution_clock> st,
      |                 ^~~~~~~~~~~~
src/scc/utils.h:66:18: warning: ‘float utils::timedur(std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >, std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >)’ defined but not used [-Wunused-function]
   66 |     static float timedur(std::chrono::time_point<std::chrono::high_resolution_clock> st,
      |                  ^~~~~~~
src/scc/utils.h:61:72: warning: ‘std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > > utils::get_time()’ defined but not used [-Wunused-function]
   61 |     static std::chrono::time_point<std::chrono::high_resolution_clock> get_time()
      |                                                                        ^~~~~~~~
x86_64-linux-gnu-g++ -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 build/temp.linux-x86_64-cpython-310/src/scc/scc.o build/temp.linux-x86_64-cpython-310/src/scc/scccmodule.o -L/usr/lib/x86_64-linux-gnu -o build/lib.linux-x86_64-cpython-310/sccc.cpython-310-x86_64-linux-gnu.so -march=corei7-avx -pthread -std=c++14
building 'llamac' extension
creating build/temp.linux-x86_64-cpython-310/src/llama
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ilib/ -I/usr/include/python3.10 -I/usr/local/lib/python3.10/dist-packages/numpy/core/include -c src/llama/llama.cpp -o build/temp.linux-x86_64-cpython-310/src/llama/llama.o -march=corei7-avx -pthread -std=c++14
src/llama/llama.cpp: In member function ‘void LLAMA::contract_bag_average()’:
src/llama/llama.cpp:225:33: warning: loop variable ‘p’ creates a copy from type ‘const std::pair<LLAMA::LLAMANode*, float>’ [-Wrange-loop-construct]
  225 |                 for (const auto p : m_node->parents)
      |                                 ^
src/llama/llama.cpp:225:33: note: use reference type to prevent copying
  225 |                 for (const auto p : m_node->parents)
      |                                 ^
      |                                 &
src/llama/llama.cpp:326:30: warning: unused variable ‘parent_eq_neigh’ [-Wunused-variable]
  326 |                         bool parent_eq_neigh = parent.first == m_node->best_neighbor;
      |                              ^~~~~~~~~~~~~~~
src/llama/llama.cpp:289:10: warning: unused variable ‘c1_time’ [-Wunused-variable]
  289 |     auto c1_time = sec(c1_end, c1_st);
      |          ^~~~~~~
src/llama/llama.cpp:293:10: warning: variable ‘c2_st’ set but not used [-Wunused-but-set-variable]
  293 |     auto c2_st = get_time();
      |          ^~~~~
src/llama/llama.cpp: In member function ‘void LLAMA::contract_set_average()’:
src/llama/llama.cpp:475:33: warning: loop variable ‘p’ creates a copy from type ‘const std::pair<LLAMA::LLAMANode*, float>’ [-Wrange-loop-construct]
  475 |                 for (const auto p : m_node->parents)
      |                                 ^
src/llama/llama.cpp:475:33: note: use reference type to prevent copying
  475 |                 for (const auto p : m_node->parents)
      |                                 ^
      |                                 &
src/llama/llama.cpp:509:14: warning: unused variable ‘pp_time’ [-Wunused-variable]
  509 |         auto pp_time = sec(prune_parents_end, prune_parents_st);
      |              ^~~~~~~
src/llama/llama.cpp:516:10: warning: unused variable ‘c1_time’ [-Wunused-variable]
  516 |     auto c1_time = sec(c1_end, c1_st);
      |          ^~~~~~~
src/llama/llama.cpp:617:10: warning: unused variable ‘c2_time’ [-Wunused-variable]
  617 |     auto c2_time = sec(c2_st, c2_end);
      |          ^~~~~~~
src/llama/llama.cpp:628:10: warning: unused variable ‘c3_time’ [-Wunused-variable]
  628 |     auto c3_time = sec(c3_end, c3_st);
      |          ^~~~~~~
src/llama/llama.cpp: In member function ‘void LLAMA::contract_single()’:
src/llama/llama.cpp:718:33: warning: loop variable ‘p’ creates a copy from type ‘const std::pair<LLAMA::LLAMANode*, float>’ [-Wrange-loop-construct]
  718 |                 for (const auto p : m_node->parents)
      |                                 ^
src/llama/llama.cpp:718:33: note: use reference type to prevent copying
  718 |                 for (const auto p : m_node->parents)
      |                                 ^
      |                                 &
src/llama/llama.cpp:751:14: warning: unused variable ‘pp_time’ [-Wunused-variable]
  751 |         auto pp_time = sec(prune_parents_end, prune_parents_st);
      |              ^~~~~~~
src/llama/llama.cpp:779:26: warning: unused variable ‘parent_eq_neigh’ [-Wunused-variable]
  779 |                     bool parent_eq_neigh = parent.first == m_node->best_neighbor;
      |                          ^~~~~~~~~~~~~~~
src/llama/llama.cpp:809:30: warning: unused variable ‘parent_eq_neigh’ [-Wunused-variable]
  809 |                         bool parent_eq_neigh = parent.first == m_node->best_neighbor;
      |                              ^~~~~~~~~~~~~~~
src/llama/llama.cpp:758:10: warning: unused variable ‘c1_time’ [-Wunused-variable]
  758 |     auto c1_time = sec(c1_end, c1_st);
      |          ^~~~~~~
src/llama/llama.cpp:848:10: warning: unused variable ‘c2_time’ [-Wunused-variable]
  848 |     auto c2_time = sec(c2_st, c2_end);
      |          ^~~~~~~
src/llama/llama.cpp:859:10: warning: unused variable ‘c3_time’ [-Wunused-variable]
  859 |     auto c3_time = sec(c3_end, c3_st);
      |          ^~~~~~~
src/llama/llama.cpp: In member function ‘void LLAMA::get_child_parent_edges()’:
src/llama/llama.cpp:891:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<long unsigned int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  891 |         for (int r = 0; r < number_of_active_ids.size(); r++)
      |                         ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/llama/llama.cpp:893:31: warning: comparison of integer expressions of different signedness: ‘int’ and ‘__gnu_cxx::__alloc_traits<std::allocator<long unsigned int>, long unsigned int>::value_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  893 |             for (int m = 0; m < number_of_active_ids[r]; m++)
src/llama/llama.cpp:906:14: warning: unused variable ‘build_desc_time’ [-Wunused-variable]
  906 |         auto build_desc_time = sec(build_desc_st, build_desc_end);
      |              ^~~~~~~~~~~~~~~
src/llama/llama.cpp: In member function ‘void LLAMA::set_descendants()’:
src/llama/llama.cpp:927:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<long unsigned int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  927 |         for (int r = 0; r < number_of_active_ids.size(); r++)
      |                         ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/llama/llama.cpp:962:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<long unsigned int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  962 |         for (int r = 0; r < number_of_active_ids.size(); r++)
      |                         ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/llama/llama.cpp:966:31: warning: comparison of integer expressions of different signedness: ‘int’ and ‘__gnu_cxx::__alloc_traits<std::allocator<long unsigned int>, long unsigned int>::value_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  966 |             for (int m = 0; m < number_of_active_ids[r]; m++)
src/llama/llama.cpp:919:40: warning: unused variable ‘last_round_descandants’ [-Wunused-variable]
  919 |         std::unordered_set<node_id_t> *last_round_descandants;
      |                                        ^~~~~~~~~~~~~~~~~~~~~~
src/llama/llama.cpp:954:14: warning: unused variable ‘build_desc_time’ [-Wunused-variable]
  954 |         auto build_desc_time = sec(build_desc_st, build_desc_end);
      |              ^~~~~~~~~~~~~~~
src/llama/llama.cpp:987:14: warning: unused variable ‘build_desc_time1’ [-Wunused-variable]
  987 |         auto build_desc_time1 = sec(build_desc_start1, build_desc_end1);
      |              ^~~~~~~~~~~~~~~~
src/llama/llama.cpp: In member function ‘void LLAMA::save_parents(std::unordered_set<LLAMA::LLAMANode*>&)’:
src/llama/llama.cpp:1003:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<LLAMA::LLAMANode*>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
 1003 |         for (int i = 0; i < active_nodes.size(); i++)
      |                         ~~^~~~~~~~~~~~~~~~~~~~~
src/llama/llama.cpp:1013:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<LLAMA::LLAMANode*>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
 1013 |         for (int i = 0; i < active_nodes.size(); i++)
      |                         ~~^~~~~~~~~~~~~~~~~~~~~
src/llama/llama.cpp:1045:10: warning: unused variable ‘sp_time’ [-Wunused-variable]
 1045 |     auto sp_time = sec(sp_end, sp_start);
      |          ^~~~~~~
src/llama/llama.cpp: In constructor ‘LLAMA::LLAMA(std::vector<unsigned int>, std::vector<unsigned int>, std::vector<float>, unsigned int, unsigned int, scalar*, unsigned int, unsigned int, unsigned int, scalar)’:
src/llama/llama.cpp:1112:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<unsigned int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
 1112 |     for (int i = 0; i < r.size(); i++)
      |                     ~~^~~~~~~~~~
src/llama/llama.cpp: In member function ‘void LLAMA::prune_to_k_neighbors()’:
src/llama/llama.cpp:1169:14: warning: unused variable ‘prune_time’ [-Wunused-variable]
 1169 |         auto prune_time = sec(st, en);
      |              ^~~~~~~~~~
In file included from src/llama/llama.h:48,
                 from src/llama/llama.cpp:17:
src/llama/utils.h: At global scope:
src/llama/utils.h:56:17: warning: ‘long int utils::timedur_long(std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >, std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >)’ defined but not used [-Wunused-function]
   56 |     static long timedur_long(std::chrono::time_point<std::chrono::high_resolution_clock> st,
      |                 ^~~~~~~~~~~~
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ilib/ -I/usr/include/python3.10 -I/usr/local/lib/python3.10/dist-packages/numpy/core/include -c src/llama/llamacmodule.cxx -o build/temp.linux-x86_64-cpython-310/src/llama/llamacmodule.o -march=corei7-avx -pthread -std=c++14
src/llama/llamacmodule.cxx: In function ‘PyObject* new_llamac(PyObject*, PyObject*)’:
src/llama/llamacmodule.cxx:63:8: warning: unused variable ‘numDimRow’ [-Wunused-variable]
   63 |   long numDimRow = PyArray_DIM(rows_in, 1);
      |        ^~~~~~~~~
src/llama/llamacmodule.cxx:65:8: warning: unused variable ‘numDimCol’ [-Wunused-variable]
   65 |   long numDimCol = PyArray_DIM(cols_in, 1);
      |        ^~~~~~~~~
src/llama/llamacmodule.cxx:67:8: warning: unused variable ‘numDimSims’ [-Wunused-variable]
   67 |   long numDimSims = PyArray_DIM(sims_in, 1);
      |        ^~~~~~~~~~
src/llama/llamacmodule.cxx:68:8: warning: unused variable ‘threshInDim’ [-Wunused-variable]
   68 |   long threshInDim = PyArray_DIM(thresholds_in, 0);
      |        ^~~~~~~~~~~
src/llama/llamacmodule.cxx:69:8: warning: unused variable ‘numDimThresh’ [-Wunused-variable]
   69 |   long numDimThresh = PyArray_DIM(thresholds_in, 1);
      |        ^~~~~~~~~~~~
src/llama/llamacmodule.cxx: In function ‘PyObject* llamac_all_nodes_coo(PyObject*, PyObject*)’:
src/llama/llamacmodule.cxx:128:42: warning: narrowing conversion of ‘obj->LLAMA::descendants_r.std::vector<unsigned int>::size()’ from ‘std::vector<unsigned int>::size_type’ {aka ‘long unsigned int’} to ‘long int’ [-Wnarrowing]
  128 |   long dims[2] = {obj->descendants_r.size(), 2};
      |                   ~~~~~~~~~~~~~~~~~~~~~~~^~
src/llama/llamacmodule.cxx:105:18: warning: unused variable ‘in_array’ [-Wunused-variable]
  105 |   PyArrayObject *in_array;
      |                  ^~~~~~~~
src/llama/llamacmodule.cxx: In function ‘PyObject* llamac_child_parent_coo(PyObject*, PyObject*)’:
src/llama/llamacmodule.cxx:166:37: warning: narrowing conversion of ‘obj->LLAMA::children.std::vector<unsigned int>::size()’ from ‘std::vector<unsigned int>::size_type’ {aka ‘long unsigned int’} to ‘long int’ [-Wnarrowing]
  166 |   long dims[2] = {obj->children.size(), 2};
      |                   ~~~~~~~~~~~~~~~~~~^~
src/llama/llamacmodule.cxx:143:18: warning: unused variable ‘in_array’ [-Wunused-variable]
  143 |   PyArrayObject *in_array;
      |                  ^~~~~~~~
src/llama/llamacmodule.cxx: In function ‘PyObject* llamac_get_round_coo(PyObject*, PyObject*)’:
src/llama/llamacmodule.cxx:215:19: warning: narrowing conversion of ‘result_size’ from ‘size_t’ {aka ‘long unsigned int’} to ‘long int’ [-Wnarrowing]
  215 |   long dims[2] = {result_size, 2};
      |                   ^~~~~~~~~~~
src/llama/llamacmodule.cxx:181:18: warning: unused variable ‘in_array’ [-Wunused-variable]
  181 |   PyArrayObject *in_array;
      |                  ^~~~~~~~
In file included from src/llama/llama.h:48,
                 from src/llama/llamacmodule.cxx:26:
src/llama/utils.h: At global scope:
src/llama/utils.h:56:17: warning: ‘long int utils::timedur_long(std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >, std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >)’ defined but not used [-Wunused-function]
   56 |     static long timedur_long(std::chrono::time_point<std::chrono::high_resolution_clock> st,
      |                 ^~~~~~~~~~~~
src/llama/utils.h:50:18: warning: ‘float utils::timedur(std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >, std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >)’ defined but not used [-Wunused-function]
   50 |     static float timedur(std::chrono::time_point<std::chrono::high_resolution_clock> st,
      |                  ^~~~~~~
src/llama/utils.h:45:72: warning: ‘std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > > utils::get_time()’ defined but not used [-Wunused-function]
   45 |     static std::chrono::time_point<std::chrono::high_resolution_clock> get_time()
      |                                                                        ^~~~~~~~

These were flagged out when building on 26/11/2023 on Google Colab (https://colab.research.google.com/drive/18t_xGjS86wk8RbrkUToziRT3XjgMLiWc?usp=sharing)

Suggested Solution I recommend using an IDE with an appropriate linter for development work as it would flag these issues during development and deployment.

crazoter avatar Nov 26 '23 04:11 crazoter