diff --git a/SDL2pp/StreamRWops.hh b/SDL2pp/StreamRWops.hh index e84a0c3..4530eda 100644 --- a/SDL2pp/StreamRWops.hh +++ b/SDL2pp/StreamRWops.hh @@ -79,7 +79,11 @@ private: template typename std::enable_if::value, size_t>::type ReadHelper(void* ptr, size_t size, size_t maxnum) { stream_.read(static_cast(ptr), size * maxnum); - size_t nread = stream_.gcount(); + + // http://en.cppreference.com/w/cpp/io/streamsize: + // "Except in the constructors of std::strstreambuf, + // negative values of std::streamsize are never used" + size_t nread = static_cast(stream_.gcount()); // eof is OK if (stream_.rdstate() == (std::ios_base::eofbit | std::ios_base::failbit))