1 // ehopt was only copying one statement from the cleanup of the B temporary 2 // into the following try block, so we lost its destructor call. 3 4 // { dg-do run } 5 6 template <class T, class U> 7 class A; 8 9 bool b; 10 int count; 11 12 template <> 13 class A<int, int> 14 { 15 public: A(int)16 A(int) { ++count; if (b) throw 1; } A(const A &)17 A(const A&) { ++count; if (b) throw 1; } 18 ~A() 19 #if __cplusplus <= 201402L throw(int)20 throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++17 } } } } 21 #else 22 noexcept(false) 23 #endif 24 { --count; if (b) throw 1; } 25 }; 26 27 typedef A<int, int> B; 28 29 template <> 30 class A<void *, void *> 31 { 32 public: A()33 A() { if (b) throw 1; } A(const B &)34 A(const B&) { if (b) throw 1; } 35 ~A() 36 #if __cplusplus <= 201402L throw(int)37 throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++17 } } } } 38 #else 39 noexcept(false) 40 #endif 41 { if (b) throw 1; } 42 }; 43 44 typedef A<void *, void *> C; 45 f()46void f() { if (b) throw 1; } 47 48 int main(void)49main (void) 50 { 51 { 52 C a(1); 53 f(); 54 } 55 return count; 56 } 57