Title
Evaluation order in aggregate initialization
Status
nad
Section
9.4.5 [dcl.init.list]
Submitter
Jason Merrill

Created on 2011-11-22.00:00:00 last changed 146 months ago

Messages

Date: 2012-10-15.00:00:00

Rationale (October, 2012):

Because this is an expression, not a declaration, the As live until the end of the full-expression.

Date: 2022-11-20.07:54:16

Issue 1030 clarified that elements of an initializer-list are evaluated in the order they are written, but does that also apply to implied expressions? That is, given:

    struct A { A(); ~A(); };
    struct B { B(int, const A& = A()); ~B(); };
    struct C { B b1, b2; };
    int main() { C{1,2}; }

Do we know that the first B is constructed before the second A? I suppose that's what we want, even though it complicates exception region nesting since the As need to live longer than the B subobject cleanups.

History
Date User Action Args
2012-11-03 00:00:00adminsetmessages: + msg4177
2012-11-03 00:00:00adminsetstatus: open -> nad
2011-11-22 00:00:00admincreate