I'm trying to understand why the destructors throwing exceptions is a very bad idea. By googling, I understand that if destructor throws, say, during destruction of the block-scope objects, the destruction of the obeject stopped and we get memory leak if there're the other objects destructors have not called for.
But by itself, the destructor throwing exceptions is so bad? For instance (the complete example):
struct A
{
int a;
char b;
A() : a(10), b('a') { }
~A(){ throw std::exception(); }
};
int main()
{
A a; //destructor throws, but there're no more objects to destruction
//therefore I think there's no memory leak
}
Do we get UB in the program above?