std::stringstream GCC Abnormal Behavior

Posted by FlorianZ on Stack Overflow See other posts from Stack Overflow or by FlorianZ
Published on 2009-10-21T06:23:30Z Indexed on 2010/05/12 20:24 UTC
Read the original article Hit count: 192

Filed under:
|
|

I have a very interesting problem with compiling a short little program on a Mac (GCC 4.2). The function below would only stream chars or strings into the stringstream, but not anything else (int, double, float, etc.) In fact, the fail flag is set if I attempt to convert for example an int into a string.

However, removing the preprocessor flag: _GLIBCXX_DEBUG=1, which is set by default in XCode for the debug mode, will yield the desired results / correct behavior.

Here is the simple function I am talking about. value is template variable of type T. Tested for int, double, float (not working), char and strings (working).

template < typename T >
const std::string Attribute<T>::getValueAsString() const
{
 std::ostringstream stringValue;
 stringValue << value;
 return stringValue.str();
}

Any ideas what I am doing wrong, why this doesn't work, or what the preprocessor flag does to make this not work anymore?

Thanks!

© Stack Overflow or respective owner

Related posts about stringstream

Related posts about gcc