title: Checking for NULL pointer in C/C++
body: <p>In a recent code review, a contributor is trying to enforce that all <code>NULL</code> checks on pointers be performed in the following manner:</p>
  
  <pre><code>int * some_ptr;
  // ...
  if (some_ptr == NULL)
  {
      // Handle null-pointer error
  }
  else
  {
      // Proceed
  }
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>int * some_ptr;
  // ...
  if (some_ptr)
  {
      // Proceed
  }
  else
  {
      // Handle null-pointer error
  }
  </code></pre>
  
  <p>I agree that his way is a little more clear in the sense that it's explicitly saying "Make sure this pointer is not NULL", but I would counter that by saying that anyone who's working on this code would understand that using a pointer variable in an <code>if</code> statement is implicitly checking for <code>NULL</code>.  Also I feel the second method has a smaller chance of introducing a bug of the ilk:</p>
  
  <pre><code>if (some_ptr = NULL)
  </code></pre>
  
  <p>which is just an absolute pain to find and debug.</p>
  
  <p>Which way do you prefer and why?</p>