Hello Otto and Rene, This is an interesting problem. I could reproduce this but could not find anything wrong. The problem occurs both on root2.25(cint5.14.50) and root3.00(cint5.14.76). Further, I tried this on a couple of compilers. On Visual C++, compiled code generated wrong output also. I suspect operator<<(ostream,T& x) does not guarantee adding '\0' at the end of string stream. Although g++ works fine under Linux, it can be just an coincidence. I read back ANSI/ISO C++ standard but can not find anything about this point. I believe you need to add '\0' at the end. buf << 7 << "_" << '\0'; Thank you Masaharu Goto ------------------------------------------------------ #ifdef __CINT__ #include </cint/include/iostream.h> #else #include <iostream.h> #include <strstrea.h> #endif t585() { ostrstream buf; buf << 7 << "_"; cout << buf.str() << endl; } main() { t585(); t585(); t585(); t585(); t585(); t585(); t585(); t585(); t585(); } ----------------------------------------------------- ### Windows Visual C++ output 7_:\WIND 7_TEM;C: 7_S;C:\W 7_OS~2\C 7_C:\PRO 7_MON\TO 7_A~1\MI 7_C98\BI 7_GRA~1\ ------------------------------------------------------ ### Windows CINT output 7_ 7_ 7_e 7_e 7_ 7_ 7_ 7_ 7_ ------------------------------------------------------ ### Linux g++ output 7_ 7_ 7_ 7_ 7_ 7_ 7_ 7_ 7_ ------------------------------------------------------ >Date: Fri, 16 Feb 2001 18:23:39 +0000 >From: Rene Brun <Rene.Brun@cern.ch> >To: Otto.Schaile@Physik.Uni-Muenchen.DE, rootdev@pcroot.cern.ch >Subject: Re: ostrstream with 3.00-05 > >Hi Masa, >This problem has been reported by Otto. > >Rene > >Otto.Schaile@Physik.Uni-Muenchen.DE wrote: >> >> Hi Rene, >> I am on 2.2.16-bl-0.1. Red Hat Linux release 6.2 (Zoot) >> >> * Version 2.25/03 14 September 2000 * >> root [0] ostrstream buf; >> root [1] buf << 7 << "_" >> (class ostream)138912716 >> root [2] cout << buf.str() <<endl; >> 7_ >> >> thats fine >> >> now with >> * Version 3.00/05 16 February 2001 * >> root [0] ostrstream buf; >> root [1] buf << 7 << "_" >> (class ostream)139462988 >> root [2] cout << buf.str() <<endl; >> 7_カ@?スカ@ >> root [3] .q >> >> this looks not so good >> Something changed with CINT? >> >> Cheers >> Otto >> >> Dr. Otto Schaile Sektion Physik, LMU Muenchen >> Phone: +49 89 289 14070 Am Coulombwall 1, D-85748 Garching, Germany >> GSM: +49 171 4312031 >> FAX: +49 89 289 14072 EMail: Otto.Schaile@Physik.Uni-Muenchen.DE
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:36 MET