Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.jason/ref7.C

raw
1 // { dg-do run }
2 // Testcase for the lifetime of a temporary object which is used to
3 // initialize a reference.
4
5 int destroyed = 0;
6
7 struct A {
8 A() { }
9 A(int) { }
10 ~A() { destroyed++; }
11 };
12
13 A a;
14 A foo () { return a; }
15
16 int main()
17 {
18 const A& ar = foo();
19 const A& ar2 = A();
20 const A& ar3 = (A)1;
21 return destroyed;
22 }