Amarghosh - 2024-08-09

I posted a query on stack overflow with sample code, but did not get any response there. Can you confirm if this is expected behaviour, or is there a way to work around this?

void f1(const char *s)
{
    printf("f1");
}

int main()
{
    char *s = calloc(10, sizeof(char));
    f1(s); // memleak is reported only if this is commented out
    return 0;
}

https://stackoverflow.com/q/78845892/165297

Is it just that cppcheck does not look in to how the called function is using the pointer, and rather relies on the data in .cfg file for deciding that? I can see how tracking the usage of a pointer across multiple functions can be complicated and performance heavy.