TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Rule:  CON#009Checked automatically with code checker

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.