Extend value tracking for member variables/functions
include <string.h>
//lint -passes(2)
class X
{
int *p;
public:
X(){ p = NULL; }
bool IsValid()const{return p != NULL;}
void Foo()
{
if(IsValid())
*p = 0; // Warning 613: Possible use of null pointer (wrong)
}
void Bar()
{
if(p != NULL)
*p = 0; // no 613 here (ok)
}
};
// Value tracking works for global variables (ok)
int pg = NULL;
bool IsValid(const int px)
{
return px != NULL;
}
void Bar()
{
if(IsValid(pg))
*pg = 0;// no 613 here (ok)
}
This issue has been addressed in the updated value tracking available in the upcoming PC-lint Plus.