title: gcc std::istream 'error: invalid cast from type ‘std::streamsize’ to type ‘std::streamsize’'
body: <p>Alright, so here is a really weird one. I am reading raw data into a buffer, nothing fancy, my code went like so:</p>
  
  <pre><code>typedef unsigned char Byte;
  /* ... */
  static Byte SerializeBuffer[2048];
  /* ... */
  std::streamsize readInBuffer = 
                  data.read((char*)SerializeBuffer, sizeof(SerializeBuffer));
  </code></pre>
  
  <p>But I would keep getting the compile error message <code>'error: invalid cast from type ‘void *’ to type ‘std::streamsize’'</code>, No idea why the compiler thought that sizeof was a void pointer. Well I tried casting it in several ways, but the same error kept happening. I ended up with this:</p>
  
  <pre><code>std::streamsize dummy = sizeof(SerializeBuffer);
  std::streamsize readInBuffer = 
                  data.read((char*)SerializeBuffer, reinterpret_cast&lt;std::streamsize&gt;(dummy));
  </code></pre>
  
  <p>Which pops up the following: <code>error: invalid cast from type ‘std::streamsize’ to type ‘std::streamsize’</code></p>
  
  <p>I am at a complete loss. Any other Ideas?</p>
  
  <p>Compiler: gcc 4.4.5<br>
  OS: Linux 2.6.35</p>
  
  <p><strong>edit:</strong>
  Same thing on Visual Studio 2010</p>