The following code leads with the cppcheck v2.6 to a stack overflow in the misra.py
//file.hpp #include <stdint.h> template<class Type> class Test { public: Test(int32_t i) : val((Type)i) { } static Test FromCompileTime(int32_t i) { return Test(i); } private: static inline Test one = FromCompileTime(1); Type val; };
with
//misra.json { "script": "misra.py" }
and
cppcheck --addon=misra.json file.hpp
Part of the output:
Checking file.hpp ... Bailing out from checking file.hpp since there was an internal error: Failed to execute 'python3 /usr/share/cppcheck/addons/runaddon.py /usr/share/cppcheck/addons/misra.py --cli file.hpp.dump'. {"file": "file.hpp", "linenr": 6, "column": 18, "severity": "style", "message": "misra violation (use --rule-texts=<file> to get proper output)", "addon": "misra", "errorId": "c2012-2.7", "extra": "Undefined"} Traceback (most recent call last): File "/usr/share/cppcheck/addons/runaddon.py", line 8, in <module> runpy.run_path(addon, run_name='__main__') File "/usr/lib/python3.8/runpy.py", line 265, in run_path return _run_module_code(code, init_globals, run_name, File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code _run_code(code, mod_globals, init_globals, File "/usr/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/usr/share/cppcheck/addons/misra.py", line 4630, in <module> main() File "/usr/share/cppcheck/addons/misra.py", line 4572, in main checker.parseDump(item) File "/usr/share/cppcheck/addons/misra.py", line 4243, in parseDump self.executeCheck(902, self.misra_9_2, cfg) File "/usr/share/cppcheck/addons/misra.py", line 4157, in executeCheck check_function(*args) File "/usr/share/cppcheck/addons/misra.py", line 2089, in misra_9_2 misra_9.misra_9_x(self, data, 902) File "/usr/share/cppcheck/addons/misra_9.py", line 407, in misra_9_x ed = getElementDef(nameToken, rawTokens) File "/usr/share/cppcheck/addons/misra_9.py", line 431, in getElementDef createRecordChildrenDefs(ed) File "/usr/share/cppcheck/addons/misra_9.py", line 474, in createRecordChildrenDefs child = getElementDef(variable.nameToken) File "/usr/share/cppcheck/addons/misra_9.py", line 431, in getElementDef createRecordChildrenDefs(ed) File "/usr/share/cppcheck/addons/misra_9.py", line 474, in createRecordChildrenDefs child = getElementDef(variable.nameToken) File "/usr/share/cppcheck/addons/misra_9.py", line 431, in getElementDef createRecordChildrenDefs(ed) [...] File "/usr/share/cppcheck/addons/misra_9.py", line 474, in createRecordChildrenDefs child = getElementDef(variable.nameToken) File "/usr/share/cppcheck/addons/misra_9.py", line 431, in getElementDef createRecordChildrenDefs(ed) File "/usr/share/cppcheck/addons/misra_9.py", line 474, in createRecordChildrenDefs child = getElementDef(variable.nameToken) File "/usr/share/cppcheck/addons/misra_9.py", line 431, in getElementDef createRecordChildrenDefs(ed) File "/usr/share/cppcheck/addons/misra_9.py", line 474, in createRecordChildrenDefs child = getElementDef(variable.nameToken) File "/usr/share/cppcheck/addons/misra_9.py", line 431, in getElementDef createRecordChildrenDefs(ed) File "/usr/share/cppcheck/addons/misra_9.py", line 474, in createRecordChildrenDefs child = getElementDef(variable.nameToken) File "/usr/share/cppcheck/addons/misra_9.py", line 430, in getElementDef ed = ElementDef("record", nameToken.str, nameToken.valueType) File "/usr/share/cppcheck/addons/misra_9.py", line 5, in __init__ self.name = str(name) RecursionError: maximum recursion depth exceeded while calling a Python object
Am I doing something wrong?
The Misra addon is not designed to handle C++ code. I think this problem can be expected.
Now after you say it, it's rather obvious. Thanks for the fast reply!
Log in to post a comment.
The following code leads with the cppcheck v2.6 to a stack overflow in the misra.py
with
and
Part of the output:
Am I doing something wrong?
The Misra addon is not designed to handle C++ code. I think this problem can be expected.
Now after you say it, it's rather obvious. Thanks for the fast reply!