[Bug c++/72768] Potential bug about the order of destructors of static objects and atexit() callbacks in C++?

lh_mouse at 126 dot com gcc-bugzilla@gcc.gnu.org
Tue Aug 2 09:28:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72768

--- Comment #6 from lh_mouse <lh_mouse at 126 dot com> ---
> But then if the delegating constructor throws you would run the destructor twice e.g.

The `atexit()` callback in question can check the `__cxa_guard` of the object
to determine whether it should call the destructor. Lack of a guard object
(when the static object has namespace scope instead of block scope) is out of
question because throwing anything out of the constructor would result in a
call to `std::terminate()`.


More information about the Gcc-bugs mailing list