1// { dg-do run } 2// GROUPS passed virtual-functions 3// virtual file 4// From: allan@ramjet.multinet.DE (Allan Brighton) 5// Subject: pos. bug in gcc-2.5.2 on hp 6// Date: 4 Nov 1993 22:57:36 -0500 7// Message-ID: <9311041820.AA05942@ramjet.multinet.DE> 8 9#include <iostream> 10#include <sstream> 11 12using namespace std; 13 14class BugStream : public ostringstream { 15public: 16 BugStream() {} 17 BugStream& eval(); 18}; 19 20 21static struct Eval_ { } eval; 22BugStream& operator<<(ostream& os, Eval_); 23 24BugStream& BugStream::eval() 25{ 26 // make sure str is null terminated 27 *this << ends; 28 29 // eval the command and set the status 30 const char* s = str().data(); 31 cerr << s << endl; 32 33 // reset the stream for the next command 34 clear(ios::goodbit); 35 // rdbuf()->freeze(0); 36 seekp(0); 37 38 return *this; 39} 40 41BugStream& operator<<(ostream& os, Eval_) 42{ 43 return ((BugStream&)os).eval(); 44} 45 46int main() { 47 BugStream bs; 48 bs << "PASS" << eval; 49} 50