title: error: cast from 'Foo*' to 'unsigned int' loses precision
body: <p>I'm trying to cast a pointer to an int (or unsigned int) and no matter what I try it doesn't want to work. </p>
  
  <p>I've tried <code>static_cast&lt;intptr_t&gt;(obj)</code>, <code>reinterpret_cast&lt;intptr_t&gt;(obj)</code>, and various combinations of C style casts, <code>intptr_t</code>'s, <code>unsigned int</code>'s, and I'm including stdint.h. From what I've read, one of the many things I've tried should work. What gives?</p>
  
  <p>I didn't bother including the code because it's exactly what I described, but since you asked, I've tried all of these plus other combinations:</p>
  
  <pre><code>void myfunc(Foo* obj)
  {
      // ...
      uintptr_t temp = reinterpret_cast&lt;uintptr_t&gt;(obj);
      uintptr_t temp = static_cast&lt;uintptr_t&gt;(obj);
      uintptr_t temp = (uintptr_t)obj;
      intptr_t temp = reinterpret_cast&lt;intptr_t&gt;(obj);
      intptr_t temp = static_cast&lt;intptr_t&gt;(obj);
      intptr_t temp = (intptr_t)obj;
      unsigned int temp = reinterpret_cast&lt;unsigned int&gt;(obj);
      unsigned int temp = static_cast&lt;unsigned int&gt;(obj);
      unsigned int temp = (unsigned int)obj;
      // ...
  }
  </code></pre>
  
  <p>They all give the exact same error. </p>