I have checked the GnuCOBOL source code and it appears CALL "SYSTEM" returns the result of the C system() call. This function does not return the exit code but the wait status. The exit code is in the least significant byte. In C, you can use the WEXITSTATUS() macro to get the exit code. I do not know if this behavior is consistent with other COBOL environments. The documentation should be updated to clarify how to interpret the result of CALL "SYSTEM".
Return value of CALL "SYSTEM" is incorrect
If I have this code: void func() {} void leak() { int *p = new int; *p = 42; } int main() { leak(); return 0; } Cppcheck correctly detects a memory leak: $ cppcheck --enable=style --template=gcc leak.cc Checking leak.cc ... leak.cc:8:1: warning: Memory leak: p [memleak] } ^ However if I add some code to leak() Cppcheck no longer detects the leak. Even if this code does not reference variable p: void leak() { int *p = new int; *p = 42; func(); } $ cppcheck --enable=style leak.cc Checking leak.cc ......
The --tempalte=gcc option does not work correctly with the -j option. If I use -j the line containing the problem is no longer displayed. Without -j: $ cppcheck --enable=style --template=gcc iconvcvt.cpp Checking iconvcvt.cpp ... iconvcvt.cpp:22:10: warning: Variable 'cd_' is assigned in constructor body. Consider performing initialization in initialization list. [useInitializationList] that.cd_ = (iconv_t)-1; ^ With -j: cppcheck -j2 --enable=style --template=gcc iconvcvt.cpp Checking iconvcvt.cpp...
When I run cppcheck on the following code: #include <cstring> #include <iconv.h> class IconvConversionDescriptor { public: IconvConversionDescriptor(const char* fromCode, const char* toCode); IconvConversionDescriptor(IconvConversionDescriptor& that); ~IconvConversionDescriptor(); private: iconv_t cd_; }; IconvConversionDescriptor::IconvConversionDescriptor(const char* fromCode, const char* toCode) : cd_(iconv_open(fromCode, toCode)) {} IconvConversionDescriptor::IconvConversionDescriptor(IconvConversionDescriptor&...
Cobcrun segfault when LOGNAME is set to empty string
error: numeric literal '1000000000000000001' exceeds limit '9223372036854775807'