https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95417
Bug ID: 95417 Summary: Static storage duration objects that are constant initialized should be destroyed after the destruction of dynamically initialized object. Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: okannen at gmail dot com Target Milestone: --- This is a bug that is here since at least GCC 5.1. Variable with static storage duration that are constant initialized should be destroyed after the destruction of all variables with static storage duration that are dynamically initialized. This is specified in the standard. This answer on SO, (by a C++ comity member I think) explain it: https://stackoverflow.com/a/27197836/5632316 This break the mental model that objects are destroyed in the reverse order of their construction (even if in this case this order is not sensible). The program whose code is bellow should output: ```` non constant delete constant delete ``` But it output the opposite: ```` non constant delete constant delete ``` #include <iostream> struct NonConstant{ NonConstant(){ std::cout<<""; } ~NonConstant(){std::cout << "non constant delete" <<std::endl;} }; struct Constant{ ~Constant(){std::cout << "constant delete" <<std::endl;} }; NonConstant a; Constant b; int main(){ }