public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: bug or not
@ 2003-09-21 16:54 Anthony Christopher'
  0 siblings, 0 replies; 3+ messages in thread
From: Anthony Christopher' @ 2003-09-21 16:54 UTC (permalink / raw)
  To: gcc-help

I suppose it is a problem with the text book I have which describes the 
behavior of this constructor.

It describes the string parameter as the string that the stream writes 
to, a destination,
rather than as an initializer.  Where can I find a spec which might 
confirm this?

Anthony Christopher

^ permalink raw reply	[flat|nested] 3+ messages in thread
* bug or not
@ 2003-09-21  5:14 Anthony Christopher'
  2003-09-21 14:59 ` Eljay Love-Jensen
  0 siblings, 1 reply; 3+ messages in thread
From: Anthony Christopher' @ 2003-09-21  5:14 UTC (permalink / raw)
  To: gcc-help

 > uname -a
Linux princess 2.4.20 #1 SMP Mon Apr 7 17:32:00 PDT 2003 i686 unknown
 > /usr/local/bin/g++ --version
g++ (GCC) 3.2.2
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 > cat gccbug.cc
#include <string>
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
   for(int i = 9; i < 11; i++){
     // When I use the constructor for ostringstream with a string
     // argument I get nothing in the string.
     string outBuffer;
     ostringstream outStr(outBuffer);
     outStr << "The number is " << i;
     cout << outBuffer << endl;
     // When I use the default constructor and the str() function to
     // refer to the internal string I get what I expect.
     ostringstream mydefault;
     mydefault << "Default gets me " << i;
     cout << mydefault.str() << endl;
   }
   return 0;
}
 > /usr/local/bin/g++ -Wall -o strange gccbug.cc
 > echo "XXXX start of output file XXXX" > junk
 > ./strange >> junk
 > echo "XXXX end of output file XXXX" >> junk
 > cat -A junk
XXXX start of output file XXXX$
$
Default gets me 9$
$
Default gets me 10$
XXXX end of output file XXXX$


Is this a bug or have I messed up?

I am not subscribed to this mailing list so please reply
to me directly or CC me.

No unusual flags used in building gcc.

Anthony Christopher

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-09-21 16:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-21 16:54 bug or not Anthony Christopher'
  -- strict thread matches above, loose matches on Subject: below --
2003-09-21  5:14 Anthony Christopher'
2003-09-21 14:59 ` Eljay Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).