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)
}
![](https://secure.gravatar.com/avatar/25f24912af20c3aa7d433a8104d6f292?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)
This issue has been addressed in the updated value tracking available in the upcoming PC-lint Plus.