|
From: Patrick J. L. <lop...@gm...> - 2013-06-05 07:18:00
|
On Tue, Jun 4, 2013 at 11:22 AM, Niall Douglas <ndo...@bl...> wrote: > This happens because until we get > C++ Modules, we can't know the order of deinit of statically allocated > objects. That is not entirely true. The order of _construction_ of static objects is not specified, but the order of _destruction_ is guaranteed by the C++ specification to be the opposite of the order of construction. This usually means that if you have arranged your code not to have dangling pointers during construction, you will also not have segfaults during destruction. (At the very least, it should make it straightforward to avoid the segfault you describe.) Also, in my experience, most C++ experts think that global static objects are usually indicative of a poor design. They encourage excessive coupling, limit reusability of components, and so forth. But this is just an opinion (and not universal) so I will leave it at that. - Pat |