exception handling core dump

#include<iostream>

using namespace std;

void a() throw(float)
{
throw 5;
}

int main()
{
try
{
a();
}
catch(int a)
{
cout<<a;
}
catch(float a)
{
cout<<a;
}
catch(...)
{
cout<<"uncaught";
}

getchar();
return 0;
}



why dis program crashes....
it is not catching the exception and not printing "uncaught" also....
Do OSs even core dump anymore?

catch (...) will catch all exceptions. There's no syntax to allow something to happen in case no exception occurs.
Last edited on
Your throw specification on a() says the function only throws floats, but then you throw an int instead.

Fix: don't use throw specifications.

Topic archived. No new replies allowed.