Hello, I have following code:
void g(const char *text); void f(const char *text) { unsigned offset = 0; if(!text) { text = "AA"; } else if(!strncmp(text,"abcd",4)) { offset = 4; } g(text + offset); }
Both Cppcheck 2.11 and online demo claim, that
[test.cpp:13]: (portability) Undefined behaviour, pointer arithmetic 'text+offset' is out of bounds.
If I remove line text = "AA"; problem disappears. It looks like cppcheck assumes I use offset 4 for text = "AA".
Best Regards Martin
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11994
Log in to post a comment.
Hello,
I have following code:
Both Cppcheck 2.11 and online demo claim, that
If I remove line text = "AA"; problem disappears.
It looks like cppcheck assumes I use offset 4 for text = "AA".
Best Regards Martin
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11994