Yes it would try to destruct twice and have odd side effects - hopefully crashing your program, but possibly not crashing but wrecking other parts of your progam in unpredictable ways.
But unfortunately, exit() apparently doesn't unwind the stack like I initially thought.
if it exit() doesn't unwind the stack, why would the destructor be called?
exit() is more complicated than I thought... This is what it says in the standard...
Calling the function void exit(int); declared in <cstdlib> (18.3) terminates the program without leaving the current block and hence without destroying any objects with automatic storage duration (12.4). If exit is called to end a program during the destruction of an object with static storage duration, the program has undefined behavior.
I have no idea what it means by
If exit is called to end a program during the destruction of an object with static storage duration, the program has undefined behavior.
(say I called exit(0). Then my program has undefined behavior while returning 0. )
It turns out that return 0 is more favorable than exit(0)