public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/95417] New: Static storage duration objects that are constant initialized should be destroyed after the destruction of dynamically initialized object. @ 2020-05-29 13:17 okannen at gmail dot com 2020-05-29 13:35 ` [Bug c++/95417] " rguenth at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: okannen at gmail dot com @ 2020-05-29 13:17 UTC (permalink / raw) To: gcc-bugs 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(){ } ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/95417] Static storage duration objects that are constant initialized should be destroyed after the destruction of dynamically initialized object. 2020-05-29 13:17 [Bug c++/95417] New: Static storage duration objects that are constant initialized should be destroyed after the destruction of dynamically initialized object okannen at gmail dot com @ 2020-05-29 13:35 ` rguenth at gcc dot gnu.org 2020-05-29 13:48 ` redi at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: rguenth at gcc dot gnu.org @ 2020-05-29 13:35 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95417 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- The standard is unclear here I think. Better not change a common implementation pattern since people may rely on current behavior. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/95417] Static storage duration objects that are constant initialized should be destroyed after the destruction of dynamically initialized object. 2020-05-29 13:17 [Bug c++/95417] New: Static storage duration objects that are constant initialized should be destroyed after the destruction of dynamically initialized object okannen at gmail dot com 2020-05-29 13:35 ` [Bug c++/95417] " rguenth at gcc dot gnu.org @ 2020-05-29 13:48 ` redi at gcc dot gnu.org 2020-07-16 16:00 ` okannen at gmail dot com 2020-07-16 16:01 ` okannen at gmail dot com 3 siblings, 0 replies; 5+ messages in thread From: redi at gcc dot gnu.org @ 2020-05-29 13:48 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95417 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- GCC, Clang and EDG all destroy b before a. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/95417] Static storage duration objects that are constant initialized should be destroyed after the destruction of dynamically initialized object. 2020-05-29 13:17 [Bug c++/95417] New: Static storage duration objects that are constant initialized should be destroyed after the destruction of dynamically initialized object okannen at gmail dot com 2020-05-29 13:35 ` [Bug c++/95417] " rguenth at gcc dot gnu.org 2020-05-29 13:48 ` redi at gcc dot gnu.org @ 2020-07-16 16:00 ` okannen at gmail dot com 2020-07-16 16:01 ` okannen at gmail dot com 3 siblings, 0 replies; 5+ messages in thread From: okannen at gmail dot com @ 2020-07-16 16:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95417 Olivier Kannengieser <okannen at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED --- Comment #3 from Olivier Kannengieser <okannen at gmail dot com> --- I have just found a paragraph in the standard that specifies that GCC behavior is standard compliant, [basic.start.term]/3: "If an object is initialized statically, the object is destroyed in the same order as if the object was dynamically initialized." ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/95417] Static storage duration objects that are constant initialized should be destroyed after the destruction of dynamically initialized object. 2020-05-29 13:17 [Bug c++/95417] New: Static storage duration objects that are constant initialized should be destroyed after the destruction of dynamically initialized object okannen at gmail dot com ` (2 preceding siblings ...) 2020-07-16 16:00 ` okannen at gmail dot com @ 2020-07-16 16:01 ` okannen at gmail dot com 3 siblings, 0 replies; 5+ messages in thread From: okannen at gmail dot com @ 2020-07-16 16:01 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95417 Olivier Kannengieser <okannen at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|FIXED |INVALID --- Comment #4 from Olivier Kannengieser <okannen at gmail dot com> --- It is thus an invalid bug. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-16 16:01 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-05-29 13:17 [Bug c++/95417] New: Static storage duration objects that are constant initialized should be destroyed after the destruction of dynamically initialized object okannen at gmail dot com 2020-05-29 13:35 ` [Bug c++/95417] " rguenth at gcc dot gnu.org 2020-05-29 13:48 ` redi at gcc dot gnu.org 2020-07-16 16:00 ` okannen at gmail dot com 2020-07-16 16:01 ` okannen at gmail dot com
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).