CWG Issue 1343 (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


1343. Sequencing of non-class initialization

Section: 6.10.1 [intro.execution]Status: C++17Submitter: Johannes SchaubDate: 2011-08-12

[Moved to DR at the November, 2016 meeting as paper P0507R0.]

The current wording does not indicate that initialization of a non-class object is a full-expression, but presumably should do so.

Additional note, April, 2013:

There is implementation variance in the treatment of the following example:

struct A { A() { puts("ctor"); } A(const A&) { puts("copy"); } const A&get() const { return *this; } ~A() { puts("dtor"); } }; struct B { B(A, A) {} };

typedef A A2[2]; A2 a = { A().get(), A().get() }; B b = { A().get(), A().get() }; int c = (A2{ A().get(), A().get() }, 0); int d = (B{ A().get(), A().get() }, 0);

int main() {}

Additional note (February, 2014):

Aggregate initialization could also involve more than one full-expression, so the limitation above to “initialization of a non-class object” is not correct.

Additional note (October, 2015):

For additional examples, consider:

int i = i++; int j = j;

The current sequencing rules do not cover these initializations.

Also, in

const int& f(const int& x) { return x; } int y = f(5);

it doesn't appear that 6.10.1 [intro.execution] paragraph 10 requires the temporary for 5 to persist until the initialization of y is complete.

Proposed resolution (June, 2016):

The resolution is given in paper P0507R0.