home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / gnu / g / lib / bug / 746 < prev    next >
Encoding:
Text File  |  1993-01-06  |  1.7 KB  |  61 lines

  1. Newsgroups: gnu.g++.lib.bug
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!isy.liu.se!garp
  3. From: garp@isy.liu.se (Johan Garpendahl)
  4. Subject: strstream bug?
  5. Message-ID: <9301051616.AA04745@lin.isy.liu.se>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Tue, 5 Jan 1993 18:16:47 GMT
  10. Approved: bug-lib-g++@prep.ai.mit.edu
  11. Lines: 48
  12.  
  13. I'm not quite sure that this is a bug, it's rather a difference in how
  14. cfront handles strstreams and how (lib)g++ handles strstreams. 
  15.  
  16. Here is an example:
  17. ////////////////////////////
  18. #include <string.h>
  19. #include <strstream.h>
  20. #include <iostream.h>
  21.  
  22. char* str1="Now is the time for all good men ... 13:34:20 beep";
  23.  
  24. main()
  25. {
  26.     istrstream istr1(str1, strlen(str1) + 1);
  27.     char buf[256];
  28.  
  29.     while(istr1 >> buf) cout << buf << " "; // Don't forget to say "beep"
  30.     cout << endl;
  31.  
  32.     istrstream istr2(str1, strlen(str1) + 1);
  33.  
  34.     while(istr2.good()) { // Try again!
  35.     istr2 >> buf;              // That's better!
  36.     cout << buf << " ";
  37.     }
  38.     cout << endl;
  39. }
  40. ////////////////////////////
  41.  
  42. Compile with cfront and it prints the whole string twice.
  43. Compile with (lib)g++ and it loses the "beep" the first time.
  44.  
  45. I can find good arguments for both behaviours.
  46. Is it the program that is badly written?
  47. Is there a definition of how it should work?
  48.  
  49. BTW, I last tried it with g++-2.3.3 and libg++-2.3.
  50.  
  51. Regards, 
  52.  
  53.     Johan
  54. ___________________________________________________________________________
  55. Johan Garpendahl                   | Email: garp@isy.liu.se
  56. Linkoping University               | Phone: +46 - 13 - 28 13 24
  57. Dept. of Electrical Engineering    | Fax  : +46 - 13 - 13 92 82
  58. S-581 83  LINKOPING // SWEDEN      | May the Source be with you.
  59.  
  60.  
  61.