CWG Issue 193 (original) (raw)

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

2025-11-05


193. Order of destruction of local automatics of destructor

Section: 11.4.7 [class.dtor]Status: TC1Submitter: Gerhard MenzlDate: 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 forX's direct members, ...

to

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