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
[Voted into the WP at the June, 2008 meeting.]
According to 8.8 [stmt.jump] paragraph 2,
On exit from a scope (however accomplished), destructors (11.4.7 [class.dtor]) are called for all constructed objects with automaticstorage duration (6.8.6.4 [basic.stc.auto]) (named objects ortemporaries) that are declared in that scope, in the reverse order oftheir declaration.
This wording is problematic for temporaries and for parameters.First, temporaries are not "declared," so this requirement does notapply to them, in spite of the assertion in the quoted text that itdoes.
Second, although the parameters of a function aredeclaredin the called function, they are constructed and destroyed in thecalling context, and the order of evaluation of the arguments isunspecified (cf 7.6.1.3 [expr.call] paragraphs 4 and 8).The order of destruction of the parameters might, therefore, bedifferent from the reverse order of their declaration.
Notes from 04/01 meeting:
Any resolution of this issue should be careful not to introducerequirements that are redundant or in conflict with those of otherparts of the IS. This is especially true in light of the pendingissues with respect to the destruction of temporaries (see issues86,124,199, and201).If possible, the wording of a resolution should simply referencethe relevant sections.
It was also noted that the temporary for a return value isalso destroyed "out of order."
Note thatissue 378 picks a nitwith the wording of this same paragraph.
Proposed Resolution (November, 2006):
Change 8.8 [stmt.jump] paragraph 2 as follows:
On exit from a scope (however accomplished),destructors(11.4.7 [class.dtor]) are called for all constructed objectswith automatic storage duration (6.8.6.4 [basic.stc.auto]) (namedobjects or temporaries) that are declared in that scope, in thereverse order of their declaration.variables with automaticstorage duration (6.8.6.4 [basic.stc.auto]) that have beenconstructed in that scope are destroyed in the reverse order of theirconstruction. [Note: For temporaries, see 6.8.7 [class.temporary].—end note] Transfer out of a loop...