October 25, 2002 try-catch | ||||
---|---|---|---|---|
| ||||
What should normally happens in the following C++ code? void ups() { int a=0,b;b/=a; } // couse divide by 0 exception class A { public: ~A() { ups(); } }; void do_some() { try { A a; ups(); } catch (...) { } } void main() { try { do_some(); } catch(...) { } } |
October 31, 2002 Re: try-catch | ||||
---|---|---|---|---|
| ||||
Posted in reply to K Sergey | Should call unexpected() (or it may be terminate() - is late here ... ) as you cannot throw within an unwind. This is one of the reasons that destructors should not throw exceptions. I'm pretty sure it's terminate(), since unexpected() is to do with mismatch wrt ex-specs. Matthew "K Sergey" <K_member@pathlink.com> wrote in message news:apbgm1$2rrf$1@digitaldaemon.com... > What should normally happens in the following C++ code? > > void ups() { int a=0,b;b/=a; } // couse divide by 0 exception > > class A { > public: > ~A() { ups(); } > }; > > void do_some() > { > try > { > A a; > ups(); > } catch (...) > { > } > } > > void main() > { > try > { > do_some(); > } > catch(...) > { > } > } > > > |
Copyright © 1999-2021 by the D Language Foundation