Will gcc's deconstructor still run if the program crashes (due to a segfault or whatever else), or only on a successful exit or end of main?
Will gcc's deconstructor still run if the program crashes (due to a segfault or whatever else), or only on a successful exit or end of main?
All bets are off as soon as your program does anything not covered by the standard - such as accessing non existent memory causing segfaults.
Plus the manual page only mentions normal exits.
Originally Posted by gcc manual
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.