title: storing a 64-bit pointer in a 32-bit integer, provided max virtual memory address <= UINT32_MAX (e.g., when RAM size <= 4GB)
body: <p>Are there any platforms (if so, which?) where something like the following can be done, provided that a runtime check confirms that there is no more than 4GB of virtual memory (or RAM) available?</p>
  
  <pre><code>// 1) cast pointer to void pointer
  // 2) cast void pointer to uint64 type
  // 3) set most significant bytes of uint64 type to 0 (might be wrong choice)
  // 4) store as uint32 type
  uint32_t trimmed_pointer = (uint64_t) (void *) pointer &amp; 0x00000000ffffffff;
  </code></pre>
  
  <p>and to get back the original pointer:</p>
  
  <pre><code>same_as_before_t *pointer = (void *) (uint64_t) trimmed_pointer
  </code></pre>
  
  <p>I realize this would probably be a terrible hack and entirely dependent on how the OS's memory manager implements virtual memory (as well as the compiler?), so I'm asking this purely out of curiosity.</p>