robotology / blockfactory

A tiny framework to wrap algorithms for dataflow programming
https://robotology.github.io/blockfactory
GNU Lesser General Public License v2.1
40 stars 16 forks source link

Compilation failure with gcc 7.3.0 and Matlab 2018b in Debug mode #13

Closed traversaro closed 5 years ago

traversaro commented 5 years ago
[ 95%] Building CXX object sources/Mex/CMakeFiles/Mex.dir/src/BlockFactory.cpp.o
/home/straversaro/src/blockfactory/sources/Mex/src/BlockFactory.cpp: In function ‘const std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > parameterTypeToString(const blockfactory::core::ParameterType&)’:
/home/straversaro/src/blockfactory/sources/Mex/src/BlockFactory.cpp:594:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
In file included from /home/straversaro/src/blockfactory/sources/Mex/src/BlockFactory.cpp:852:0:
/usr/local/MATLAB/R2018b/simulink/include/simulink.c: In function ‘int_T ssWriteRTWWorkVect(SimStruct*, const char_T*, int_T, ...)’:
/usr/local/MATLAB/R2018b/simulink/include/simulink.c:1847:7: warning: ‘</arg></arguments></diag></diag_root>’ directive writing 37 bytes into a region of size 14 [-Wformat-overflow=]
 int_T ssWriteRTWWorkVect(SimStruct    *S,
       ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from /usr/include/c++/7/cstdio:42,
                 from /usr/include/c++/7/ext/string_conversions.h:43,
                 from /usr/include/c++/7/bits/basic_string.h:6352,
                 from /usr/include/c++/7/string:52,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/array:39,
                 from /usr/include/c++/7/tuple:39,
                 from /usr/include/c++/7/bits/unique_ptr.h:37,
                 from /usr/include/c++/7/memory:80,
                 from /home/straversaro/src/blockfactory/sources/Core/include/BlockFactory/Core/Parameters.h:12,
                 from /home/straversaro/src/blockfactory/sources/Core/include/BlockFactory/Core/Block.h:12,
                 from /home/straversaro/src/blockfactory/sources/Mex/src/BlockFactory.cpp:12:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:34:43: note: ‘__builtin___sprintf_chk’ output 224 or more bytes into a destination of size 200
       __bos (__s), __fmt, __va_arg_pack ());
                                           ^
diegoferigo commented 5 years ago

I managed to reproduce this problem on both gcc 7 and gcc 8. Unfortunately the Mex target cannot be tested by our CI pipeline, and I usually use clang during my development activities (that does not show this error).

Unfortunately the origin of this warning comes from a macro expansion in simulink.c, which we do not control since it is shipped with Matlab.

I recently increased a lot the strictness in the debug configuration (see TargetCompileWarnings.cmake), probably the only way would be to disable that warning, at least on the Mex target. If you configure the project passing TREAT_WARNINGS_AS_ERRORS=OFF it compiles fine.