Re: C++: std::ostringstream default ctor problems
Re: C++: std::ostringstream default ctor problems
- Subject: Re: C++: std::ostringstream default ctor problems
- From: Rush Manbert <email@hidden>
- Date: Mon, 28 Sep 2009 10:03:17 -0700
On Sep 27, 2009, at 6:12 PM, Dan Caugherty wrote:
Hey all --
This may or may not be a relevant topic for this group, so please
gently point me to the right place if not. If so, then please read on.
I have the following snippet of code compiling successfully on Xcode
3.2 and GCC 4.2:
const std::string
foobar::to_string() const
{
std::ostringstream oss;
oss << *this; // gdb says odd things happen right here
return oss.str();
}
Under GCC 4.2, I see the following error:
malloc: *** error for object 0xa0451db0: pointer being freed was not
allocated
*** set a breakpoint in malloc_error_break to debug
..and sure enough, the ostringstream instance is trying to free a
buffer that it never allocated. Naughty naughty.
Is this a known issue with GCC 4.2, or am I just doing something
wrong?
Hi Dan,
This is a total shot in the dark, based on a similar error that is
observed with Boost.test.
By any chance is the foobar class a derived class? And, if so, does
its base class NOT have a virtual destructor?
If these are true, try making the base class destructor virtual.
- Rush
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden