Possible bug: ostringstream

Hi All,
I have come across a bug associated the following code, it work fine in
VS2008 release mode and crash in debug mode, I did some research found
it should be a bug in the microsoft implementation of ostringstream, Is
anybody know how to fix this or alternative way? Any ideas would be
appreciated.
BTW: I must use std::ostringstream because actually lot of dependencies
dll was developed with std::ostringstream.str() return. I don't want
change the dependencies project it wastes too much.
std::string result( "" );
size_t length = source.size();
std::ostringstream offset;
long offsetsToSource = 12135L;
offset << offsetsToSource;
std::string nsource = offset.str();
result.reserve( nsource.length() * 1.6 );
std::for_each( nsource.begin(), nsource.end(),ToXML( result, "\"&<>" )
);
msvcp90d.dll!std::_Container_base_secure::_Orphan_all() Line 223 + 0x5
bytes C++
msvcp90d.dll!std::_Container_base_secure::~_Container_base_secure()
Line 115 C++
msvcp90d.dll!std::_String_base::~_String_base() + 0x11 bytes C++
msvcp90d.dll!std::_String_val ::~basic_string getMetaData.dll!getQMAttributes(Av::Generic::ContainerIF *
pcFile=0x026a0924, Av::Generic::MasterMobIF * pMasterMob=0x0278d234,
Av::Generic::TapeMobIF * pTapeMob=0x0279275c, MobInfo & mobInfo={...})
Line 748 + 0x73 bytes C++

AMDG On 12/8/2010 10:32 PM, Jammy Cheng Chen wrote:
I have come across a bug associated the following code, it work fine in VS2008 release mode and crash in debug mode, I did some research found it should be a bug in the microsoft implementation of ostringstream, Is anybody know how to fix this or alternative way? Any ideas would be appreciated.
BTW: I must use std::ostringstream because actually lot of dependencies dll was developed with std::ostringstream.str() return. I don't want change the dependencies project it wastes too much.
std::string result( "" ); size_t length = source.size(); std::ostringstream offset; long offsetsToSource = 12135L; offset<< offsetsToSource;
std::string nsource = offset.str(); result.reserve( nsource.length() * 1.6 ); std::for_each( nsource.begin(), nsource.end(),ToXML( result, "\"&<>" ));
Um. What exactly does this have to do with Boost? In Christ, Steven Watanabe

It didn't related Boost in following piece of code, but I know some guys was discussed the similar issue in this mail list before, so I want get help from there. Thanks Jammy -----Original Mail----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] Steven Watanabe Send Date 2010年12月9日 18:22 Sent: boost-users@lists.boost.org Subject: Re: [Boost-users] Possible bug: ostringstream AMDG On 12/8/2010 10:32 PM, Jammy Cheng Chen wrote:
I have come across a bug associated the following code, it work fine in VS2008 release mode and crash in debug mode, I did some research found it should be a bug in the microsoft implementation of ostringstream, Is anybody know how to fix this or alternative way? Any ideas would be appreciated.
BTW: I must use std::ostringstream because actually lot of dependencies dll was developed with std::ostringstream.str() return. I don't want change the dependencies project it wastes too much.
std::string result( "" ); size_t length = source.size(); std::ostringstream offset; long offsetsToSource = 12135L; offset<< offsetsToSource;
std::string nsource = offset.str(); result.reserve( nsource.length() * 1.6 ); std::for_each( nsource.begin(), nsource.end(),ToXML( result, "\"&<>" ));
Um. What exactly does this have to do with Boost? In Christ, Steven Watanabe _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

2010/12/10 Jammy Cheng Chen
It didn't related Boost in following piece of code, but I know some guys was discussed the similar issue in this mail list before, so I want get help from there.
Thanks Jammy
-----Original Mail----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] Steven Watanabe Send Date 2010年12月9日 18:22 Sent: boost-users@lists.boost.org Subject: Re: [Boost-users] Possible bug: ostringstream
AMDG
On 12/8/2010 10:32 PM, Jammy Cheng Chen wrote:
I have come across a bug associated the following code, it work fine in VS2008 release mode and crash in debug mode, I did some research found it should be a bug in the microsoft implementation of ostringstream, Is anybody know how to fix this or alternative way? Any ideas would be appreciated.
BTW: I must use std::ostringstream because actually lot of dependencies dll was developed with std::ostringstream.str() return. I don't want change the dependencies project it wastes too much.
std::string result( "" ); size_t length = source.size(); std::ostringstream offset; long offsetsToSource = 12135L; offset<< offsetsToSource;
std::string nsource = offset.str(); result.reserve( nsource.length() * 1.6 ); std::for_each( nsource.begin(), nsource.end(),ToXML( result, "\"&<>" ));
Jammy, Please don't top post in this list. It's highly unlikely there's a bug in ostringstream. I suggest you shorten your code bit by bit and then you'll home in on the problem. Write out the std::for_each() as a for loop. What you want to get to is a minimum size program that exhibits the problem. Just doing that will probably help find the error which I'll wager is with your code. If you have a nice *small* program that shows the problem, then post this to comp.lang.c++ newsgroup (you can access that through Google Groups) and they'll help you out. Also, take a good look at the stack trace! Pete
participants (3)
-
Jammy Cheng Chen
-
PB
-
Steven Watanabe