int* ptrF();
void f()
{
int* p = ptrF();
bool pOK = p && true;
if (pOK)
*p = 12; // Lint thinks p might be nullptr here
}
Lint gives a warning
C:\lint_test\nullptr_with_init.cpp(8): Issue 613: (Warning -- Possible use of null pointer 'p' in argument to operator 'unary *' [Reference: file C:\lint_test\nullptr_with_init.cpp: line 6])
Does anyone know if there is a setting to make Lint more "clever" and to see that pOK cannot be true if p == nullptr?
This would be much better than changing the code or suppressing the warning like this
*p = 12; //lint !e613
Aucun commentaire:
Enregistrer un commentaire