You create an array of 5 Test objects, but you throw an exception after creating 3 complete objects. An exception is thrown when in the constructor 4 4th object. Building a 4 th object is not complete until the final bracket of the constructor is reached.
The stack unpacks the call to the destructor for those 3 fully constructed objects in the opposite order in which they were created, since objects 4 th and 5 th were never constructed, the destructor for them is never called.
The rule for exclusion is:
After an exception is thrown by destructors for all fully created objects inside this area, it will be called.
A fully created object is one whose constructor is called purely without any exceptions.
source share