If you call exit
, the destructor will not be called.
From the C++ standard (ยง3.6.1/4):
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.