lundi 25 avril 2016

should we use exit in C++?

According to C++ reference

exit terminates the process normally, performing the regular cleanup for terminating programs.

Normal program termination performs the following (in the same order): Objects associated with the current thread with thread storage duration are destroyed (C++11 only). Objects with static storage duration are destroyed (C++) and functions registered with atexit are called. All C streams (open with functions in ) are closed (and flushed, if buffered), and all files created with tmpfile are removed. Control is returned to the host environment.

Note that objects with automatic storage are not destroyed by calling exit (C++).

as far as i know, when the process terminated, all the storage used by the process are reclaimed, so what's the impact that objects with automatic storage are not destroyed?

Aucun commentaire:

Enregistrer un commentaire