Quote Originally Posted by Feoggou View Post
I've read that the STL list throws an exception on push_back if an error occurs. Perhaps it sounds silly, but do I really have to make sure I catch every exception?
Nope----you only need to catch those exceptions which you have some idea how to recover from. If the exception is insurmountable (such as out of memory), you may as well let it propagate and kill the program.

the same question applies to using statements as char str[20]; or int x; - if it cannot allocate the memory the program would crash
Since those statements use stack memory, they'll never crash the program unless you're running out of stack space which indicates a problem elsewhere in the code; this should not be a normal concern. Stack overflows usually indicate either that you're trying to put enormous arrays on the stack (put the really big ones on the heap), or you have infinite recursion somewhere (fix it).

and I suppose that after the program is ended there might be memory leaks.
On modern systems, it's impossible to have memory leaks after the program is ended. When the process terminates, all of the memory it used, leaked or not, goes back to the OS. The concern is how to avoid memory leaks during execution. To that end, RAII is your friend. So long as all resource deallocation is handled by the destructor of some object on the stack (say a smart pointer, STL container, or custom object), memory leaks are almost impossible even in the face of exceptions.