User Activity

  • Posted a comment on discussion General Discussion on cppcheck

    Inspired by this post in a recent discussion also involving leaks and loops I tested if a leak is detected when the pointer returned from malloc is stored in a member of a struct. Indeed, in the following code cppcheck detects a memory leak: int main() { for (int n=0; n < 1; n++) { }; struct { char * buf; } test; test.buf = malloc(10); return 0; }

  • Posted a comment on discussion General Discussion on cppcheck

    Using the snippet below cppcheck reports 'memleak' in addition to 'unreadVariable' and 'unusedAllocatedMemory': int main() { char * buf = malloc(10); return 0; } cppcheck testmemleak.c --enable=all --inconclusive But 'memleak' is no longer reported when the code includes a for loop: int main() { for (int n=0; n < 1; n++) { } char * buf = malloc(10); return 0; } 'unreadVariable' and 'unusedAllocatedMemory' are still reported however. Is this a bug or am I missing something obvious? Same behavior using...

View All

Personal Data

Username:
opersvik
Joined:
2022-02-24 12:44:46.470000

Projects

  • No projects to display.

Personal Tools

Monday.com Logo