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 
12 using namespace std;
13 
14 class BugStream : public ostringstream {
15 public:
BugStream()16     BugStream() {}
17     BugStream& eval();
18 };
19 
20 
21 static struct Eval_ { } eval;
22 BugStream& operator<<(ostream& os, Eval_);
23 
eval()24 BugStream& 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 
41 BugStream& operator<<(ostream& os, Eval_)
42 {
43     return ((BugStream&)os).eval();
44 }
45 
main()46 int main() {
47     BugStream bs;
48     bs << "PASS" << eval;
49 }
50