Index: lib/Support/raw_ostream.cpp =================================================================== --- lib/Support/raw_ostream.cpp +++ lib/Support/raw_ostream.cpp @@ -613,10 +613,17 @@ assert(FD >= 0 && "File already closed."); pos += Size; +#ifdef _WIN64 + // Windows _write() requires unsigned 32 bit input for 'count', + // however to follow POSIX a value above unsigned max should not be used. + // Win64 size_t is 64 bit so int 32 max is used below. + size_t MaxWriteSize = _I32_MAX; +#else // The maximum write size is limited to SSIZE_MAX because a write // greater than SSIZE_MAX is implementation-defined in POSIX. // Since SSIZE_MAX is not portable, we use SIZE_MAX >> 1 instead. size_t MaxWriteSize = SIZE_MAX >> 1; +#endif #if defined(__linux__) // It is observed that Linux returns EINVAL for a very large write (>2G).