I went through the C++ FAQ 2nd Edition, FAQ 9.04- What is an exception specification? .
It is mentioned here that if we throw an unexpected exception from a function whose signature defines a set of predefined exception types, it should call unexpected()->terminate()->abort() . But my program catches an unexpected exception and does not abort() it, why?
#include<iostream> using namespace std; class Type1{}; class Type2{}; class Type3{}; void func() throw(Type1, Type2) { throw Type3(); } int main() { try{ func(); } catch (Type1 &obj1) { cout << "Type1 is caught" << endl; } catch (Type2 &obj2) { cout << "Type2 is caught" << endl; } catch (Type3 &obj3) { cout << "Type3 is caught" << endl; } }
Here I get the output of Type3 is caught , which should not have happened.
IDE: VS2013
c ++ exception abort
Inquusitive
source share