V713. The pointer was utilized in the logical expression before it was verified against nullptr in the same logical expression.
The analyzer has detected an issue when a pointer is checked for being nullptr after having been used. Unlike the V595 diagnostic, this one covers the range of one logical statement.
Here's an incorrect example.
if (P->x != 0 && P != nullptr) ....
In this case, the second check doesn't make any sense. If 'P' equals nullptr, a memory access error will occur when trying to dereference the null pointer. Something is obviously wrong in this code. The easiest way out is to swap the checks in the logical statement:
if (P != nullptr && P->x != 0) ....
However, it is always recommended in such cases to additionally carry out code review to find out if that is exactly what the programmer wanted. Perhaps the pointer by itself cannot be nullptr and the check is therefore excessive. Or perhaps a wrong variable is dereferenced or checked for being nullptr. Such cases have to be approached individually and there's no general recommendation to give on that.
This diagnostic is classified as:
You can look at examples of errors detected by the V713 diagnostic.