1 // PR c++/33799 2 // { dg-do run } 3 4 extern "C" void abort(); 5 6 int c, d; 7 8 #if __cplusplus >= 201103L 9 #define THROWS noexcept(false) 10 #else 11 #define THROWS 12 #endif 13 14 struct X 15 { XX16 X(bool throws) : throws_(throws) { ++c; } XX17 X(const X& x) : throws_(x.throws_) { ++c; } ~XX18 ~X() THROWS 19 { 20 ++d; 21 if (throws_) { throw 1; } 22 } 23 private: 24 bool throws_; 25 }; 26 f()27X f() 28 { 29 X x(true); 30 return X(false); 31 } 32 g()33X g() 34 { 35 return X(true),X(false); 36 } 37 h()38void h() 39 { 40 #if __cplusplus >= 201103L 41 []{ return X(true),X(false); }(); 42 #endif 43 } 44 main()45int main() 46 { 47 try { f(); } 48 catch (...) {} 49 50 try { g(); } 51 catch (...) {} 52 53 try { h(); } 54 catch (...) {} 55 56 if (c != d) 57 throw; 58 } 59