This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bug or not


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]