Synopsis: | Don't compare an address to null |
Language: | C++ |
Severity Level: | 2 |
Category: | Conversions |
Description: |
Comparing an address to null will always be false. So if this happens it is probably not intended. For example: #include <stdio.h> class Foo {}; void var(Foo* foo) { if (&foo == nullptr) return; printf("YES\n"); } will always print "YES". Probably if (foo == nullptr) return; was meant. |