From Bugzilla Helper: User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.4.0 i686) The following short sample of C++ code does not compile (see Steps to Reproduce) Reproducible: Always Steps to Reproduce: Try to compile following code sample by g++: === snip === #include <sstream> #include <string> void foo(const std::ostringstream &testStream) { } main() { std::ostringstream testStream; std::string testString; foo((static_cast<std::ostringstream &> (testStream << testString))); foo((static_cast<std::ostringstream &> (std::ostringstream() << testString))); } === snip === Actual Results: g++ cast.cc cast.cc: In method `ostream::ostream (const ostream &)': /usr/include/g++-3/streambuf.h:128: `ios::ios (const ios &)' is private cast.cc:16: within this context cast.cc: In function `int main ()': cast.cc:16: could not convert `ostream(1, ((&ostringstream(1, 2)) + 176))' to `ostream &' /usr/include/g++-3/std/bastring.h:654: in passing argument 1 of `operator<< (ostream &, const basic_string<charT, traits, Allocator> &) [with charT = char, traits = string_char_traits<char>, Allocator = __default_alloc_template<true, 0>]' Expected Results: Either cleanly compiled code, or (in the event the code is not correct) error messages regarding _both_ foo() calls, not only one. gcc version 2.96 20000731 (Red Hat Linux 7.0) gcc-2.96-69 gcc-c++-2.96-69 libstdc++-2.96-69 libstdc++-devel-2.96-69
sstream in gcc-2.96-RH is young (was not present at all in 2.95.x) and has issues like this. As it works properly in libstdc++-v3 (on gcc-3_0-branch) where it is completely rewritten and as fixing this would require rewriting *stringstream support once again, I'm deferring this; it will be fixed as soon as gcc-3.0 makes it into the distribution.