This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/72768] Potential bug about the order of destructors of static objects and atexit() callbacks in C++?
- From: "lh_mouse at 126 dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 02 Aug 2016 09:27:52 +0000
- Subject: [Bug c++/72768] Potential bug about the order of destructors of static objects and atexit() callbacks in C++?
- Auto-submitted: auto-generated
- References: <bug-72768-4@http.gcc.gnu.org/bugzilla/>
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()`.