Xref: utzoo comp.lang.c++:10797 comp.std.c++:487 Path: utzoo!attcan!telly!lethe!torsqnt!news-server.csri.toronto.edu!rutgers!psuvax1!wuarchive!uunet!fernwood!lia!jgro From: jgro@lia (Jeremy Grodberg) Newsgroups: comp.lang.c++,comp.std.c++ Subject: Order of destructor calls for auto objects Message-ID: <1990Dec14.221247.9487@lia> Date: 14 Dec 90 22:12:47 GMT Reply-To: jgro@lia.com (Jeremy Grodberg) Followup-To: comp.std.c++ Lines: 29 I cannot find anywhere in the ARM where the order of destruction of automatic objects is defined. Am I missing something? If not, I propose that the ANSI standard add the following to section 6.6 of the ARM: Objects are guaranteed to be destroyed in the reverse of their order of creation. Take, for exampe, the following block: { foo a; foo b; foo c; count << "Hello world\n"; } We are already guaranteed that a will be constructed first, then b, then c, according to section 6.7. I want to also have the guarantee that on exit from scope, first c will be destroyed, then b, then a. This has important implications for objects which reference other objects. It appears that CFront 2.0 (from AT&T) already does this, but I would like it to be formalized. Comments? -- Jeremy Grodberg "I don't feel witty today. Don't bug me." jgro@lia.com