Why is C++ std::list::clear() not calling destructors?

Your list is of pointers. Pointers don't have destructors. If you want the destructor to be called you should try list<test> instead.


A better alternative to freeing pointers using delete, or using something that abstracts that away (such as a smart pointers or pointer containers), is to simply create the objects directly on the stack.

You should prefer test t; over test * t = new test(); You very rarely want to deal with any pointer that owns a resource, smart or otherwise.

If you were to use a std::list of 'real' elements, rather than pointers to elements, you would not have this problem.