I wrote the following program
#include <iostream>
#include <stdexcept>
class Myclass
{
public:
~Myclass()
{
throw 1;
}
};
void fun()
{
Myclass obj;
}
int main()
{
try
{
fun();
}
catch (const std::exception& e)
{
std::cout << e.what();
}
catch(...)
{
std::cout << " ... default Catch" << std::endl;
}
std::cout << "Normal" << std::endl;
return 0;
}
When I run the program above in mode C++98
(cpp.sh), it prints
... default Catch
Normal
When I run it in mode C++14
, it doesn't print anything. Why is this behavior changing?
I understand that whenever an exception occurs, and any destructor
(in the process of expanding the stack) throws any exception, it terminates the application. But here, only a single exception is excluded from the block try
that is from destructor
.
source
share