1 // { dg-do run } 2 // Test for proper handling of temporaries in ?: exprs. 3 4 extern "C" int printf (const char *, ...); 5 int c = 0, d = 0; 6 7 class A { 8 public: A()9 A() { ++c; } A(const A &)10 A(const A&) { ++c; } ~A()11 ~A() { ++d; } 12 }; 13 f(const A & a)14A f (const A& a) 15 { 16 return (c ? A() : A()); 17 } 18 main()19int main() 20 { 21 { 22 f (c ? A() : A()); 23 } 24 printf ("%d %d\n", c, d); 25 return c != d || c != 2; 26 } 27