OSDN Git Service

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