This is the mail archive of the 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]

Re: FW: ostringstream: problems with str() function

On Thu, Aug 24, 2006 at 04:36:22PM +0200, Jordan, Laszlo (GE Healthcare) wrote:
> Hi,
> I had a crash in our software, which occured randomly. The valgrind logs
> and the stack trace pointed to a code snippet, which uses ostringstream
> for data conversion. (int -> string, float -> string, double-> string).
> After changing the ostringstream conversion to sprintf, the crash in the
> application no more occured and the valgrind log was clear as well. It
> seems the problem is in the str() function of ostringstream.
> Consider the following test program in order to reproduce the bug:
> #include <iostream>
> #include <strstream>
> #include <sstream>
> #include <vector>
> #include <string>
> int main()
> {
>         std::vector<std::string> v;
>         {
>                 std::ostringstream sstr;
>                 sstr << (double)1.12;
>                 v.push_back(sstr.str());
>         }
>         return 1;
> }

I used the exact command line you used, with g++ 3.4.2:

> $ g++ -g -O2 -D__STL_DEBUG -DDEBUG test.c

but I am not seeing the valgrind bug that you are seeing.

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