This is the mail archive of the
mailing list for the GCC project.
Re: FW: ostringstream: problems with str() function
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: "Jordan, Laszlo (GE Healthcare)" <Laszlo dot Jordan at ge dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 24 Aug 2006 12:20:23 -0700
- Subject: Re: FW: ostringstream: problems with str() function
- References: <5B122FD931231D408AC32630D1B1F7290D6304A3@BUDMLVEM03.e2k.ad.ge.com>
On Thu, Aug 24, 2006 at 04:36:22PM +0200, Jordan, Laszlo (GE Healthcare) wrote:
> 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;
> 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.