Aaron Danen - 4 days ago

this sort of code is analyzed properly and throws no errors

typedef char ** STR;
void f() {
   void *buf;
   STR s = (STR) &buf;
}

however, if the typedefs are not present and cppcheck doesn't know what STR is

void f() {
   void *buf;
   STR s = (STR) &buf;
}

iscast() in tokenlist.cpp returns false for (STR) and the & is parsed as a bitwise AND, instead of the address-of operator. Because the & is a binary operator on unitialized data, this example throws a false positive:

examples/uninit.c:3:19: error: Uninitialized variable: buf [uninitvar]
STR s = (STR) &buf;