The following code compiles, but the result of the first line of main is poor
(it prints the address of the string):
#include <iostream>
#include <sstream>
using namespace std;
template<typename A, typename B>
basic_ostream<A,B>& tic(basic_ostream<A,B>& o)
{
return o;
}
template<typename A, typename B>
basic_ostream<A,B>& tac(basic_ostream<A,B>& o)
{
if( ostringstream* oo = dynamic_cast<ostringstream*>(&o) ) {
cout << oo->str() << endl;
}
return o;
}
int main()
{
ostringstream() << "tac alone does not give a nice result" << tac;
ostringstream() << tic << "tic+tac together work" << tac;
}
#if 0
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.0 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt
--enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr
--disable-werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.2 (Debian 4.0.2-2)
#endif
--
Summary: poor ostringstream output
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: aburger at cea dot fr
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25410