www.digitalmars.com         C & C++   DMDScript  

c++ - try-catch

reply K Sergey <K_member pathlink.com> writes:
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(...)
{
}
}
Oct 25 2002
parent "Matthew Wilson" <dmd synesis.com.au> writes:
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(...)
 {
 }
 }
Oct 31 2002