Compilation error gcc/g++ 13.2.1 clang 17.0.6 cmake 3.29.2
iweave1 opened this issue · 1 comments
Bug category
- [ x] bug - compilation error
- bug - compilation warning
- bug - runtime error
- bug - runtime warning
- bug - logic error
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
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<char>]’ 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<char>]’ 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<bool(char)>*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::function<bool(char)>::_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<char>]’:
/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<char>]’ 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<char>]’ 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<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).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<char>]’:
/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
- cross-platform issue - linux
- cross-platform issue - windows
- cross-platform issue - macos
Environment Details:
- OS: Linux
- OS Version: Kernel 6.8.9-3
- Compiler: gcc/g++
- Compiler version: 13.2.1
Additional context
Also got this error. How to fix compilation?