title: C++: Is it safe to cast pointer to int and later back to pointer again?
body: <p>Is it safe to cast pointer to int and later back to pointer again?</p>
  
  <p>How about if we know if the pointer is 32 bit long and int is 32 bit long?</p>
  
  <pre><code>long* juggle(long* p) {
      static_assert(sizeof(long*) == sizeof(int));
      int v = reinterpret_cast&lt;int&gt;(p); // or if sizeof(*)==8 choose long here
      do_some_math(v); // prevent compiler from optimizing
      return reinterpret_cast&lt;long*&gt;(v);
  }
  
  int main() {
      long* stuff = new long(42);
      long* ffuts = juggle(stuff); 
      std::cout &lt;&lt; "Is this always 42? " &lt;&lt; *ffuts &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>Is this covered by the Standard?</p>