Search code examples
c++nullptrpc-lint

PC Lint and check for possible nullptr


My PC Lint V9.00k is silent in a pretty straightforward situation when I would expect a warning, even on -w3. Does anyone know if there are some settings that make Lint checking this case?

int* fp() { return 0; }
void f()
{
      int* p = fp();
      *p = 2; // I would expect something like "Issue 613: (Warning -- Possible use of null pointer..." here
}

Solution

  • For value tracking PC-lint needs to process the code multiple times. I.e. you need to use at least -passes(2) in the configuration.