title: Casting NULL to void in C++
body: <p>I ran across a puzzling notation:</p>
  
  <pre><code>if(ptr != (void)(NULL)) {
      //some action
  }
  </code></pre>
  
  <p>So it expanded to</p>
  
  <pre><code>if(ptr != (void)((void *)0)) {
      //some action
  }
  </code></pre>
  
  <p>which seems at least strange.
  Is there really any rationale behind that or is it simply pointless, or even wrong? It compiled fine, though (on linux / gcc, don't remember version).</p>
  
  <p>-<em>EDIT</em>-</p>
  
  <p>I checked that code today, and here's new info:
  First of all, the casting was used in a macro, and it expanded to</p>
  
  <pre><code>return (void)((void*)0);
  </code></pre>
  
  <p>within a function returning void.
  The code compiles using gcc (GCC) 4.1.2 20080704 on (Red Hat 4.1.2-50).
  So, is this statement equivalent to</p>
  
  <pre><code>return void;
  </code></pre>
  
  <p>which is equivalent to</p>
  
  <pre><code>return;
  </code></pre>
  
  <p>or is there something more to that?</p>