title: Left-shift by (64 > shift > 32) bits on UINT64 in VS shifts only 32 bits
body: <p>I am writing a DLL plugin for a 32bit program on Win64, compiled as Win32/Debug in Visual Studio 2015. I need to left bit-shift an unsigned char (defined upstream) by 56 bits into an UINT64, so that 0xFF should become 0xFF000000000000.</p>
  
  <p>What's actually happening is that for any shift value greater than 32, the result is a shift of (shift - 32) bits, with the higher 32 bits of my target UINT64 become all-1, so that:</p>
  
  <pre><code>int     NmeaPgn::sf_get_bytes(TCanMessage *m, UINT8 start_byte, UINT8 bytes)
  {
      UINT64 r = 0; /* Could need to fetch up to 8 bytes, as in 60928 */
      INT8 i;
  
      for (i = start_byte + bytes - 1; i &gt;= start_byte; --i)
      {
          r |= (m-&gt;data[i] &lt;&lt; 8 * (i - start_byte));
      }
  ...
  }
  </code></pre>
  
  <p>Using the VS debugger, I see that for:</p>
  
  <pre><code>m-&gt;data[i] == 0xC0
  i == 0x7
  start_byte == 0
  bytes == 8 (so that shift == 8 * (7 - 0) == 56)
  
  then:
  r == 0xFFFFFFFFc0000000
  </code></pre>
  
  <p>I have read:</p>
  
  <p><a href="https://msdn.microsoft.com/en-us/library/336xbhcz.aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/336xbhcz.aspx</a></p>
  
  <p><a href="https://stackoverflow.com/questions/40951434/c-bitwise-left-shift-by-32">C++ bitwise left shift by 32</a></p>
  
  <p><a href="https://stackoverflow.com/questions/33058340/left-shift-an-integer-by-32-bits">Left shift an integer by 32 bits</a></p>
  
  <p>The closest to an answer I can see is Andrey Nasonov's answer (<a href="https://stackoverflow.com/a/33058550/7817631">https://stackoverflow.com/a/33058550/7817631</a>) to the latter, but I am on a 64-bit machine (Win7-64 on Core i5), so I would not expect this to be directly relevant.</p>