User Activity

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, I found a false negative regarding the rule arrayIndexOutOfBounds. Cppcheck misses an out-of-bounds write when the array is accessed through a pointer alias. int a[2]; void f() { int *p = a; p[2] = 0; } Actual result Cppcheck does not report arrayIndexOutOfBounds. Replacing p[2] = 0 with a[2] = 0 produces the warning. Expected result Cppcheck should report the out-of-bounds write through the alias. Verification The issue was reproduced with: cppcheck --output-format=xmlv2 --enable=all array_alias.cpp...

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, I found a false negative regarding the rule arrayIndexOutOfBounds. Cppcheck misses an out-of-bounds write when the array expression is written as the address of its first element. int a[2]; void f() { (&a[0])[2] = 0; } Actual result Cppcheck does not report arrayIndexOutOfBounds. Replacing (&a[0])[2] = 0 with a[2] = 0 produces the warning. The form ((int *)a)[2] = 0 is also missed. Expected result Cppcheck should report the out-of-bounds write in these equivalent subscript forms. Verification...

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, I found a false negative regarding the rule resourceLeak. Cppcheck misses the resource leak when the null check uses a local alias of the file pointer. #include <cstdio> int f() { const FILE *a = fopen("input.txt", "r"); const FILE *b = a; if (!b) return 0; return 0; } Actual result Cppcheck does not report resourceLeak. Removing b and changing the condition to if (!a) produces the warning. Expected result Cppcheck should report the missing fclose in both forms. Verification The issue was reproduced...

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, I found a false negative regarding the rule memleak. Cppcheck misses the leak when the allocated buffer is accessed through a pointer-to-pointer alias. #include <stdlib.h> int f(void) { int result = 0; char *a = malloc(10); char **b = &a; if (*b) { (*b)[0] = 0; result = (*b)[0]; } return result; } Actual result Cppcheck does not report memleak. Removing b and replacing each *b access with a produces the warning. Expected result Cppcheck should report the missing free in both forms. Verification...

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, I found a false negative regarding the rule invalidContainer. Cppcheck misses the use of an invalidated iterator when the vector is accessed through a reference alias. #include <vector> void f() { std::vector<int> items{1, 2, 3}; std::vector<int> &values = items; auto iter = values.begin(); values.erase(iter); ++iter; } Actual result Cppcheck does not report invalidContainer. Removing the reference declaration and replacing values with items produces the warning. Expected result Cppcheck should...

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, I found a false negative regarding the rule invalidContainer. Cppcheck misses the use of an invalidated vector iterator when the increment is written as an explicit operator call. #include <vector> void f() { std::vector<int> items{1, 2, 3}; std::vector<int>::iterator iter; for (iter = items.begin(); iter != items.end(); iter.operator++()) { if (*iter == 2) items.erase(iter); } } Actual result Cppcheck does not report invalidContainer. Replacing iter.operator++() with ++iter produces the warning....

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, I found a false negative regarding the rule autoVariables. Cppcheck misses an escaping local address when it passes through a pointer temporary. void f(int **out) { int local = 1; int *temporary = &local; *out = temporary; } Actual result Cppcheck does not report autoVariables. Replacing the last two statements with *out = &local; produces the warning. Expected result Cppcheck should report that the address of the local variable is assigned through the output parameter in both forms. Verification...

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, I found a false negative regarding the rule arrayIndexOutOfBounds. Cppcheck misses an out-of-bounds write when array indexing is written as pointer arithmetic. int a[2]; void f() { *(a + 2) = 0; } Actual result Cppcheck does not report arrayIndexOutOfBounds. Replacing *(a + 2) = 0 with a[2] = 0 produces the warning. Expected result Cppcheck should report the out-of-bounds write in both forms. Verification The issue was reproduced with: cppcheck --output-format=xmlv2 --enable=all array_pointer.cpp...

View All

Personal Data

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

Projects

  • No projects to display.

Personal Tools