cppcheck 2.3 crashes in CheckClass::constructors on such code:
template <typename T> class A { private: T m; public: A& operator=() { return *this; } }; A<decltype(SOMETHING)> a;
Backtrace:
#0 0x0000000000762b51 in CheckClass::constructors (this=0x7ffd650b44e0) at lib/checkclass.cpp:173 #1 0x0000000000774fd2 in CheckClass::runChecks (this=0xdc9040 <_ZN12_GLOBAL__N_18instanceE>, tokenizer=0x7ffd650b4ff0, settings=0x7ffd650b60e8, errorLogger=0x7ffd650b5ed0) at lib/checkclass.h:65 #2 0x0000000000857e03 in CppCheck::checkNormalTokens (this=0x7ffd650b5ed0, tokenizer=...) at lib/cppcheck.cpp:949 #3 0x000000000085509f in CppCheck::checkFile (this=0x7ffd650b5ed0, filename="test.cpp", cfgname="", fileStream=...) at lib/cppcheck.cpp:751 #4 0x00000000008518af in CppCheck::check (this=0x7ffd650b5ed0, path="test.cpp") at lib/cppcheck.cpp:391 #5 0x0000000000a5626d in CppCheckExecutor::check_internal (this=0x7ffd650b6bc0, cppcheck=..., argv=0x7ffd650b6f58) at cli/cppcheckexecutor.cpp:921 #6 0x0000000000a5486e in CppCheckExecutor::check (this=0x7ffd650b6bc0, argc=3, argv=0x7ffd650b6f58) at cli/cppcheckexecutor.cpp:232 #7 0x0000000000a5a523 in main (argc=3, argv=0x7ffd650b6f58) at cli/main.cpp:95
Valgrind:
==4002== Invalid read of size 4 ==4002== at 0x762B51: CheckClass::constructors() (checkclass.cpp:173) ==4002== by 0x774FD1: CheckClass::runChecks(Tokenizer const*, Settings const*, ErrorLogger*) (checkclass.h:65) ==4002== by 0x857E02: CppCheck::checkNormalTokens(Tokenizer const&) (cppcheck.cpp:949) ==4002== by 0x85509E: CppCheck::checkFile(std::string const&, std::string const&, std::istream&) (cppcheck.cpp:751) ==4002== by 0x8518AE: CppCheck::check(std::string const&) (cppcheck.cpp:391) ==4002== by 0xA5626C: CppCheckExecutor::check_internal(CppCheck&, int, char const* const*) (cppcheckexecutor.cpp:921) ==4002== by 0xA5486D: CppCheckExecutor::check(int, char const* const*) (cppcheckexecutor.cpp:232) ==4002== by 0xA5A522: main (main.cpp:95) ==4002== Address 0xc is not stack'd, malloc'd or (recently) free'd
cmd:
cppcheck --enable=all test.cpp
Should be fixed by this PR: https://github.com/danmar/cppcheck/pull/3129
Log in to post a comment.
cppcheck 2.3 crashes in CheckClass::constructors on such code:
Backtrace:
Valgrind:
cmd:
Should be fixed by this PR: https://github.com/danmar/cppcheck/pull/3129