title: Why is static_cast of void* to another type allowed?
body: <p>I was just reading this thread:
  <a href="https://stackoverflow.com/questions/3725975/simple-c-pointer-casting">Simple c++ pointer casting</a></p>
  
  <p>And that got me to thinking why a static_cast between different pointer types is not allowed (except in the cases in which it is) <em>unless</em> you static_cast to a void* as an intermediary step. It seems to me that either both or neither should be allowed. Here is an example:</p>
  
  <pre><code>char*          cs;
  unsigned char* ucs;
  
  cs = reinterpret_cast&lt;char*&gt;(ucs);                  // 1) allowed, of course
  cs = static_cast&lt;char*&gt;(ucs);                       // 2) not allowed: incompatible pointer types
  cs = static_cast&lt;char*&gt;( static_cast&lt;void*&gt;(ucs) ); // 3) now it's allowed!
  </code></pre>
  
  <p>It seems to me that if #3 is possible then #2 should be allowed as well. Or conversely, if #2 is not allowed on the grounds that the pointers are not compatible (necessitating a reinterpret_cast) then perhaps static_casting <em>from</em> a void* to anything should not be allowed on the grounds of pointer incompatibility. (Casting <em>to</em> a void* from any other pointer is always okay, of course.)</p>
  
  <p>So why isn't one of those possilities true - that #2 and #3 are either both allowed or neither allowed? Why does it instead work as shown in my example?</p>