2 // { dg-do run { target c++11 } }
4 template<typename T> using id = T;
5 struct S { S () { s++; } ~S () { s--; } S (int) { s++; } static int s; };
9 bar (bool cond, bool cond2)
11 if (S::s != (cond ? cond2 ? 7 : 5 : cond2 ? 8 : 9))
16 foo (bool cond, bool cond2)
19 // temporary array has same lifetime as a
20 S&& a = id<S[3]>{1, 2, 3}[i];
21 // temporary S has same lifetime as b
22 const S& b = static_cast<const S&>(0);
23 // exactly one of the four temporaries is lifetime-extended
24 S&& c = cond ? cond2 ? id<S[3]>{1, 2, 3}[i] : static_cast<S&&>(0)
25 : cond2 ? id<S[4]>{1, 2, 3, 4}[i] : id<S[5]>{1, 2, 3, 4, 5}[i];