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