home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / g / lib / bug / 799 < prev    next >
Encoding:
Text File  |  1993-01-25  |  2.7 KB  |  87 lines

  1. Path: sparky!uunet!cis.ohio-state.edu!cs.rice.edu!dougm
  2. From: dougm@cs.rice.edu (Doug Moore)
  3. Newsgroups: gnu.g++.lib.bug
  4. Subject: 2.3: ostrstream and freeze
  5. Date: 25 Jan 1993 20:49:24 -0500
  6. Organization: GNUs Not Usenet
  7. Lines: 74
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-lib-g++@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <9301250337.AA08048@cs.rice.edu>
  12.  
  13. Unfreezing a previously frozen (with str) ostrstream, when that
  14. ostrstream has a fixed, user-supplied buffer, causes the ostrstream
  15. destructor to inappropriately delete the user-supplied buffer.
  16.  
  17. The program that follows should print, in an endless sequence,
  18. "Hello!" and a memory address.  And with the Sun C++ implementation of
  19. strstreams, it does.  With libg++, it crashes after the first
  20. iteration.
  21.  
  22. Sun sparc.  Sunos 4.1.2.  g++ 2.3.3, with patches.  libg++ 2.3, with
  23. patches.  Verbose compiler output:
  24. ======================================================================
  25. g++ jnk.cc -o a.out -g -v -Wall
  26. Reading specs from /blossom/lib/gcc-lib/sun4/2.3.3/specs
  27. gcc version 2.3.3
  28.  /blossom/lib/gcc-lib/sun4/2.3.3/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix -g -Wall jnk.cc /usr/tmp/cca07996.i
  29. GNU CPP version 2.3.3 (sparc)
  30.  /blossom/lib/gcc-lib/sun4/2.3.3/cc1plus /usr/tmp/cca07996.i -quiet -dumpbase jnk.cc -g -Wall -version -o /usr/tmp/cca07996.s
  31. GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
  32.  as -o /usr/tmp/cca079961.o /usr/tmp/cca07996.s
  33.  /blossom/lib/gcc-lib/sun4/2.3.3/ld -e start -dc -dp -o a.out /lib/crt0.o -L/blossom/lib/gcc-lib/sun4/2.3.3 -L/blossom/lib /usr/tmp/cca079961.o -lg++ -lgcc -lc -lg -lgcc
  34.  
  35. ======================================================================
  36.  
  37. libg++ program output
  38.  
  39. ======================================================================
  40.  
  41. 0xf7fff6c8
  42. Hello!
  43. Segmentation fault
  44.  
  45. ======================================================================
  46.  
  47. sun c++ program output (abbreviated)
  48.  
  49. ======================================================================
  50.  
  51. Hello!
  52. 0xf7fff6dc
  53. Hello!
  54. 0xf7fff6dc
  55. Hello!
  56. 0xf7fff6dc
  57.  
  58. ======================================================================
  59.  
  60. Program source:
  61.  
  62. ======================================================================
  63.  
  64. #include <iostream.h>
  65. #include <strstream.h>
  66.  
  67. int main(int, char*[])
  68. {
  69.   for(;;)
  70.     {
  71.       char buf[100];
  72.       ostrstream strut(buf, sizeof(buf));
  73.       strut << "Hello!" << ends;
  74.       char *s = strut.str();
  75.       cout << (void*)s << endl;
  76.       cout << s << endl;
  77.       strut.rdbuf()->freeze(0);
  78.     }
  79.   return 0;
  80. }
  81.  
  82. ======================================================================
  83.  
  84. Doug Moore
  85. (dougm@cs.rice.edu)
  86.  
  87.