alandefreitas / matplotplusplus

Matplot++: A C++ Graphics Library for Data Visualization 📊🗾
https://alandefreitas.github.io/matplotplusplus/
MIT License
4.34k stars 334 forks source link

Compilation error gcc/g++ 13.2.1 clang 17.0.6 cmake 3.29.2 #403

Closed iweave1 closed 3 months ago

iweave1 commented 6 months ago

Bug category

Describe the bug

fails to compile with the below error: matplotplusplus/source/matplot/util/common.cpp:54:48: error: ignoring attributes on template argument ‘int ()(FILE)’ [-Werror=ignored-attributes] 54 | std::unique_ptr<FILE, decltype(&PCLOSE)> pipe(POPEN(cmd.c_str(), "r"), | ^ cc1plus: all warnings being treated as errors make[2]: [source/matplot/CMakeFiles/matplot.dir/build.make:230: source/matplot/CMakeFiles/matplot.dir/util/common.cpp.o] Error 1 make[1]: [CMakeFiles/Makefile2:3147: source/matplot/CMakeFiles/matplot.dir/all] Error 2 make: *** [Makefile:156: all] Error 2

Steps to Reproduce

# git clone https://github.com/alandefreitas/matplotplusplus.git
cd matplotplusplus
mkdir build
cd build
cmake .. <options> -DCMAKE_BUILD_TYPE=Release

Output

```console cmake .. -DCMAKE_BUILD_TYPE=Release Setting global options Looking for -fsanitize=address Adding -fsanitize=address Looking for -fsanitize=leak Adding -fsanitize=leak Looking for -fsanitize=undefined Adding -fsanitize=undefined Setting matplotplusplus compiler options CMAKE_INSTALL_PREFIX=/usr/local CMAKE_INSTALL_LIBDIR=lib -- Configuring done (0.5s) -- Generating done (2.2s) -- Build files have been written to: ~/matplotplusplus/build (myVenv) [eric@bosque build]$ make [ 0%] Building CXX object source/3rd_party/CMakeFiles/nodesoup.dir/nodesoup/src/algebra.cpp.o [ 0%] Building CXX object source/3rd_party/CMakeFiles/nodesoup.dir/nodesoup/src/fruchterman_reingold.cpp.o [ 0%] Building CXX object source/3rd_party/CMakeFiles/nodesoup.dir/nodesoup/src/kamada_kawai.cpp.o [ 0%] Building CXX object source/3rd_party/CMakeFiles/nodesoup.dir/nodesoup/src/layout.cpp.o [ 0%] Building CXX object source/3rd_party/CMakeFiles/nodesoup.dir/nodesoup/src/nodesoup.cpp.o [ 1%] Linking CXX static library libnodesoup.a [ 1%] Built target nodesoup [ 1%] Building CXX object source/matplot/CMakeFiles/matplot.dir/backend/backend_interface.cpp.o [ 1%] Building CXX object source/matplot/CMakeFiles/matplot.dir/backend/gnuplot.cpp.o In file included from /usr/include/c++/13.2.1/functional:59, from ~/matplotplusplus/source/matplot/util/common.h:12, from ~/matplotplusplus/source/matplot/backend/gnuplot.cpp:9: In constructor ‘std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]’, inlined from ‘std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]’ at /usr/include/c++/13.2.1/bits/regex_automaton.h:149:4, inlined from ‘std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_alt(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits]’ at /usr/include/c++/13.2.1/bits/regex_automaton.h:251:24, inlined from ‘void std::__detail::_Compiler<_TraitsT>::_M_disjunction() [with _TraitsT = std::__cxx11::regex_traits]’ at /usr/include/c++/13.2.1/bits/regex_compiler.tcc:103:18: /usr/include/c++/13.2.1/bits/std_function.h:405:42: error: ‘*(std::function*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State::.std::__detail::_State_base::)).std::function::_M_invoker’ may be used uninitialized [-Werror=maybe-uninitialized] 405 | : _Function_base(), _M_invoker(__x._M_invoker) | ~~~~^~~~~~~~~~ In file included from /usr/include/c++/13.2.1/regex:65, from ~/matplotplusplus/source/matplot/backend/gnuplot.cpp:11: /usr/include/c++/13.2.1/bits/regex_automaton.h: In member function ‘void std::__detail::_Compiler<_TraitsT>::_M_disjunction() [with _TraitsT = std::__cxx11::regex_traits]’: /usr/include/c++/13.2.1/bits/regex_automaton.h:246:17: note: ‘__tmp’ declared here 246 | _StateT __tmp(_S_opcode_alternative); | ^~~~~ In member function ‘bool std::_Function_base::_M_empty() const’, inlined from ‘std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = bool; _ArgTypes = {char}]’ at /usr/include/c++/13.2.1/bits/std_function.h:574:25, inlined from ‘std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]’ at /usr/include/c++/13.2.1/bits/std_function.h:407:6, inlined from ‘std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]’ at /usr/include/c++/13.2.1/bits/regex_automaton.h:149:4, inlined from ‘std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_alt(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits]’ at /usr/include/c++/13.2.1/bits/regex_automaton.h:251:24, inlined from ‘void std::__detail::_Compiler<_TraitsT>::_M_disjunction() [with _TraitsT = std::__cxx11::regex_traits]’ at /usr/include/c++/13.2.1/bits/regex_compiler.tcc:103:18: /usr/include/c++/13.2.1/bits/std_function.h:247:37: error: ‘*(const std::_Function_base*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State::.std::__detail::_State_base::)).std::_Function_base::_M_manager’ may be used uninitialized [-Werror=maybe-uninitialized] 247 | bool _M_empty() const { return !_M_manager; } | ^~~~~~~~~~ /usr/include/c++/13.2.1/bits/regex_automaton.h: In member function ‘void std::__detail::_Compiler<_TraitsT>::_M_disjunction() [with _TraitsT = std::__cxx11::regex_traits]’: /usr/include/c++/13.2.1/bits/regex_automaton.h:246:17: note: ‘__tmp’ declared here 246 | _StateT __tmp(_S_opcode_alternative); | ^~~~~ cc1plus: all warnings being treated as errors make[2]: *** [source/matplot/CMakeFiles/matplot.dir/build.make:90: source/matplot/CMakeFiles/matplot.dir/backend/gnuplot.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:3147: source/matplot/CMakeFiles/matplot.dir/all] Error 2 make: *** [Makefile:156: all] Error 2 ```

Platform

Environment Details:

Additional context

Laserlicht commented 3 months ago

Also got this error. How to fix compilation?