OSDN Git Service

7d8af475ba8862b0a3854b6adf3cda84a369dc66
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.law / dtors2.C
1 // { dg-do run  }
2 // GROUPS passed destructors
3 #include <stdio.h>
4
5 int destruct = 0;
6
7 class bla {
8
9 public:
10
11         inline bla(char * jim) { ; };
12
13         inline ~bla() { destruct++; if (destruct == 2) printf ("PASS\n");};
14 };
15
16 class ulk {
17
18 public:
19
20         inline ulk() {};
21         inline ~ulk() {};
22
23         void funk(const bla & bob) { ;};
24              //       ^ interestingly, the code compiles right if
25              //         this & is deleted (and therefore the parameter
26              //         passed as value)
27 };
28
29 int main() {
30
31         ulk dumm;
32
33         dumm.funk(bla("laberababa"));  // this compiles correctly
34
35         dumm.funk((bla)"laberababa");  // this produces incorrect code -
36                                        // the temporary instance of
37                                        // the class "bla" is constructed
38                                        // but never destructed...
39
40
41 }