User Activity

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, I found a false negative regarding the rule arrayIndexOutOfBounds. In the following C++ program, cppcheck should report an arrayIndexOutOfBounds warning because a dynamic array of size 2 is accessed at index 2. However, cppcheck reports no such warning. int *a = new int[2]; int main() { a[0] = 0; a[1] = 0; a[2] = 0; return a[0]; } Actual result Cppcheck reports no arrayIndexOutOfBounds warning. Expected result Cppcheck should report arrayIndexOutOfBounds for the write to a[2]. Verification The...

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, I found a false negative regarding the rule accessMoved. Cppcheck reports accessMoved when a moved std::string declared through decltype(std::string{"test"}) is accessed directly. However, if that moved-from object is first queried with empty(), cppcheck misses the later access. #include <iostream> #include <string> #include <utility> int main() { decltype(std::string{"test"}) s = "test"; std::string n = std::move(s); if (s.empty()) { } std::cout << s << '\n' << std::flush; return 0; } Here,...

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, I found false negatives regarding the rule accessMoved involving lambda expressions. Cppcheck should report accessMoved warnings for the following two programs because both access a std::string object after it has been moved from. However, cppcheck reports no accessMoved warning. Case 1: moved object passed through a lambda rvalue-reference parameter #include <iostream> #include <string> #include <utility> int main() { std::string s = "test"; auto f = [](std::string &&m) { std::string n = std::move(m);...

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, I found a false positive / malformed warning regarding the rule accessMoved. In the following program, cppcheck correctly reports that s is accessed after std::move(s). However, it also reports an extra accessMoved warning for the symbol :, which is not a variable. #include <string> #include <utility> void foo(std::string); int main() { std::string s = "test"; foo(std::move(s)); for (char c : s) { } } Actual result Cppcheck reports two accessMoved warnings: <error id="accessMoved" severity="warning"...

View All

Personal Data

Username:
marktiwnzhao
Joined:
2026-07-21 12:08:18.193000

Projects

  • No projects to display.

Personal Tools

Monday.com Logo