home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.g++.lib.bug
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!isy.liu.se!garp
- From: garp@isy.liu.se (Johan Garpendahl)
- Subject: strstream bug?
- Message-ID: <9301051616.AA04745@lin.isy.liu.se>
- Sender: gnulists@ai.mit.edu
- Organization: GNUs Not Usenet
- Distribution: gnu
- Date: Tue, 5 Jan 1993 18:16:47 GMT
- Approved: bug-lib-g++@prep.ai.mit.edu
- Lines: 48
-
- I'm not quite sure that this is a bug, it's rather a difference in how
- cfront handles strstreams and how (lib)g++ handles strstreams.
-
- Here is an example:
- ////////////////////////////
- #include <string.h>
- #include <strstream.h>
- #include <iostream.h>
-
- char* str1="Now is the time for all good men ... 13:34:20 beep";
-
- main()
- {
- istrstream istr1(str1, strlen(str1) + 1);
- char buf[256];
-
- while(istr1 >> buf) cout << buf << " "; // Don't forget to say "beep"
- cout << endl;
-
- istrstream istr2(str1, strlen(str1) + 1);
-
- while(istr2.good()) { // Try again!
- istr2 >> buf; // That's better!
- cout << buf << " ";
- }
- cout << endl;
- }
- ////////////////////////////
-
- Compile with cfront and it prints the whole string twice.
- Compile with (lib)g++ and it loses the "beep" the first time.
-
- I can find good arguments for both behaviours.
- Is it the program that is badly written?
- Is there a definition of how it should work?
-
- BTW, I last tried it with g++-2.3.3 and libg++-2.3.
-
- Regards,
-
- Johan
- ___________________________________________________________________________
- Johan Garpendahl | Email: garp@isy.liu.se
- Linkoping University | Phone: +46 - 13 - 28 13 24
- Dept. of Electrical Engineering | Fax : +46 - 13 - 13 92 82
- S-581 83 LINKOPING // SWEDEN | May the Source be with you.
-
-
-