From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gabriel Dos Reis To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org Subject: Re: c++/2320: incorrect order of destruction of function parameters Date: Mon, 19 Mar 2001 11:06:00 -0000 Message-id: <20010319190603.20857.qmail@sourceware.cygnus.com> X-SW-Source: 2001-03/msg00136.html List-Id: The following reply was made to PR c++/2320; it has been noted by GNATS. From: Gabriel Dos Reis To: James.Kanze@dresdner-bank.com Cc: gcc-gnats@gcc.gnu.org Subject: Re: c++/2320: incorrect order of destruction of function parameters Date: 19 Mar 2001 19:56:07 +0100 James.Kanze@dresdner-bank.com writes: [...] | According to ISO 14882:1998, paragraph 6.6/2: "On exit from scope | (however accomplished), destructors are called for all constructed | objects with automatic storage duration (named objects or temporaries) | that are declared in that scope, in the REVERSE order of their | declaration." You will note that the objects 3 and 4, above, are | destructed in the order of their declaration, not the reverse order. | >How-To-Repeat: | Compile function with: | g++ --verbose orderdtors.cc -o order | Then execute program with | order | Output is | A::A(): 1 | B::B(): 2 | A::A(A): 3 | B::B(B): 4 | A::~A(): 3 | B::~B(): 4 | B::~B(): 2 | A::~A(): 1 Hi, I can confirm the bug you're reporting in gcc-2.95.2. However "gcc version 3.0 20010314 (prerelease)" gives the correct behavior A::A(): 1 B::B(): 2 A::A(A): 3 B::B(B): 4 B::~B(): 4 A::~A(): 3 B::~B(): 2 A::~A(): 1 -- Gaby CodeSourcery, LLC http://www.codesourcery.com