From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,31159a2bf808ff37,start X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2003-01-30 05:34:42 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: banderet@nagra.com (Gregoire Banderet) Newsgroups: comp.unix.tru64 Subject: iostream bug ? Date: 30 Jan 2003 05:34:41 -0800 Organization: http://groups.google.com/ Message-ID: NNTP-Posting-Host: 212.249.41.206 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1043933681 17830 127.0.0.1 (30 Jan 2003 13:34:41 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 30 Jan 2003 13:34:41 GMT Xref: archiver1.google.com comp.unix.tru64:9471 > uname -mrpsv OSF1 V4.0 1530 alpha > cat stream.cxx #include #include int main(int NbArgs, char *pszArgs[]) { std::ostringstream ostrs; std::string strIn = "This is a string of 129 bytes...................................................................................................."; //std::string strIn = "This is a string of 128 bytes..................................................................................................."; #ifdef WORKAROUND // we write the string per blocks of 128 bytes. long NbBytesWritten = 0; long NbBytesToWrite = strIn.length(); long const NbBytesMax = 128; std::string strInLocalCopy = strIn; std::ostream &os = ostrs; while (NbBytesWritten < strIn.length()) { NbBytesToWrite = NbBytesToWrite > NbBytesMax ? NbBytesMax : NbBytesToWrite; os.write(strInLocalCopy.c_str(), NbBytesToWrite); strInLocalCopy.erase(0, NbBytesToWrite); NbBytesWritten += NbBytesToWrite; NbBytesToWrite = strIn.length() - NbBytesWritten; } #else // !WORKAROUND ostrs << strIn; ostrs.flush(); #endif // WORKAROUND std::cout << ostrs.str() << std::endl; } > cxx -w0 -D__USE_STD_IOSTREAM stream.cxx -o stream > ./stream > cxx -w0 -D__USE_STD_IOSTREAM -DWORKAROUND stream.cxx -o stream > ./stream This is a string of 129 bytes....................................................................................................