2012-04-10 Jason Merrill Red Hat BZ 750545 * method.c (locate_dtor): Lazily declare the destructor. --- gcc/cp/method.c +++ gcc/cp/method.c @@ -870,6 +870,8 @@ synthesize_exception_spec (tree type, tr tree locate_dtor (tree type, void *client ATTRIBUTE_UNUSED) { + if (CLASSTYPE_LAZY_DESTRUCTOR (type)) + lazily_declare_fn (sfk_destructor, type); return CLASSTYPE_DESTRUCTORS (type); } --- gcc/testsuite/g++.dg/eh/dtor3.C +++ gcc/testsuite/g++.dg/eh/dtor3.C @@ -0,0 +1,36 @@ +// Red Hat bug 750545 +// { dg-do run } + +class excep {}; +class A +{ +public: + ~A() { throw excep(); } +}; + +class B +{ + A a; +}; + +class C +{ + B b; +}; + +void f() +{ + C* c = new C(); + + try + { + delete c; + } + catch(...) + {} +} + +int main() +{ + f(); +}