aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.law/dtors2.C
blob: ebf961239966ee167f1c7c37a88e7f8068500942 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// GROUPS passed destructors
#include <stdio.h>

int destruct = 0;

class bla {

public:

        inline bla(char * jim) { ; };

        inline ~bla() { destruct++; if (destruct == 2) printf ("PASS\n");};
};

class ulk {

public:

        inline ulk() {};
        inline ~ulk() {};

        void funk(const bla & bob) { ;};
             //       ^ interestingly, the code compiles right if
             //         this & is deleted (and therefore the parameter
             //         passed as value)
};

int main() {

        ulk dumm;

        dumm.funk(bla("laberababa"));  // this compiles correctly

        dumm.funk((bla)"laberababa");  // this produces incorrect code -
                                       // the temporary instance of
                                       // the class "bla" is constructed
                                       // but never destructed...


}