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