The class was also instantiated as a static function-scope object, and this was giving me issues with the mutex already being gone when function() was called by the class destructor. I changed the mutex to be a member of the class rather than as above (as I should have done to begin with) and all is well, but I want to understand a bit more about the order of destruction for these variables.
Hi surender,
Thanks for the reply. I understand that they are destroyed when the program exits, my question is on the order they are destroyed in if there is more than one. For example:
Are there any specifications what order these (ob1, ob2, ob3) will be destroyed in?
I can write some code to check my compiler, but I'd like to know if there are any specifications or if it is compiler-dependent.
You shouldn't rely on static objects being destructed in any particular order, as it is unpredictable. Assume they're destructed at the same time.
Actually, this assumption is valid for anything that happens after main() returns.