| 1 |
// { dg-do run } |
| 2 |
// GROUPS passed destructors |
| 3 |
// dtor file |
| 4 |
// Message-Id: <[email protected]> |
| 5 |
// From: [email protected] (Doug Moore) |
| 6 |
// Subject: 2.3.3: premature dtor of temp? |
| 7 |
// Date: Sun, 24 Jan 93 15:17:07 CST |
| 8 |
|
| 9 |
#include <stdio.h> |
| 10 |
#include <stdlib.h> |
| 11 |
|
| 12 |
int killed = 0; |
| 13 |
|
| 14 |
class Foo |
| 15 |
{ |
| 16 |
int a; |
| 17 |
public: |
| 18 |
Foo() |
| 19 |
:a(0) {;} |
| 20 |
~Foo() { killed++;} |
| 21 |
Foo& operator << (int b) |
| 22 |
{ |
| 23 |
a += b; |
| 24 |
if (killed) |
| 25 |
{ |
| 26 |
printf ("FAIL\n"); |
| 27 |
exit (1); |
| 28 |
} |
| 29 |
return *this; |
| 30 |
} |
| 31 |
}; |
| 32 |
|
| 33 |
int main() |
| 34 |
{ |
| 35 |
Foo() << 1 << 3 << 5 << 7; |
| 36 |
printf ("PASS\n"); |
| 37 |
} |
| 38 |
|