This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-18


193. Order of destruction of local automatics of destructor

Section: 11.4.7  [class.dtor]     Status: TC1     Submitter: Gerhard Menzl     Date: 7 Jan 2000

The Standard is not clear whether automatic objects in a destructor are destroyed before or after the destruction of the class's base and member subobjects. That is, given

    struct S { ~S(); };

    struct T {
        S x;
        ~T() {
            S y;
        };
    };

which will be destroyed first, x or y?

Proposed resolution (10/00):

In 11.4.7 [class.dtor] paragraph 6, change

A destructor for class X calls the destructors for X's direct members, ...
to
After executing the body of the destructor and destroying any automatic objects allocated within the body, a destructor for class X calls the destructors for X's direct members, ...