I
iftekhar
hi there ,
consider the followinf code
#include <iostream>
#include <stdexcept>
using namespace std;
int main (void)
{
try
{
int i = 5;
throw i;
}
catch (int j)
{
try
{
double d = 4.5;
throw d;
}
catch(...)
{
cout << "got d" << endl;
try
{
int k = 5;
throw k;
}
catch (...)
{
float f = 5.5;
throw f;
}
}
}
catch(float g)
{
cout << "got float g" << endl;
}
catch (...)
{
cout << "unknown error" << endl;
}
cout << "done" << endl;
}
compiled with gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-52)
I expected the output of the program to be
got d
got float g
done
but the output is just
got d
i tried to debug it and it seems that the ' throw f; ' causes the
program to receive SIGABRT
and try to do an assembly level debug revealed it fails in the
__cxa_throw function and then calls the terminate
in a similar situation where objects are thrown rather than intrinsic
types it throws logic_error
any one have any idea why?
thanks for reading.
consider the followinf code
#include <iostream>
#include <stdexcept>
using namespace std;
int main (void)
{
try
{
int i = 5;
throw i;
}
catch (int j)
{
try
{
double d = 4.5;
throw d;
}
catch(...)
{
cout << "got d" << endl;
try
{
int k = 5;
throw k;
}
catch (...)
{
float f = 5.5;
throw f;
}
}
}
catch(float g)
{
cout << "got float g" << endl;
}
catch (...)
{
cout << "unknown error" << endl;
}
cout << "done" << endl;
}
compiled with gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-52)
I expected the output of the program to be
got d
got float g
done
but the output is just
got d
i tried to debug it and it seems that the ' throw f; ' causes the
program to receive SIGABRT
and try to do an assembly level debug revealed it fails in the
__cxa_throw function and then calls the terminate
in a similar situation where objects are thrown rather than intrinsic
types it throws logic_error
any one have any idea why?
thanks for reading.