Title
Sequencing of non-class initialization
Status
c++17
Section
6.9.1 [intro.execution]
Submitter
Johannes Schaub

Created on 2011-08-12.00:00:00 last changed 81 months ago

Messages

Date: 2016-11-15.00:00:00

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

Date: 2016-06-15.00:00:00

Proposed resolution (June, 2016):

The resolution is given in paper P0507R0.

Date: 2015-10-15.00:00:00

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.9.1 [intro.execution] paragraph 10 requires the temporary for 5 to persist until the initialization of y is complete.

Date: 2014-02-15.00:00:00

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.

Date: 2013-05-03.00:00:00

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() {}
Date: 2011-08-12.00:00:00

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

History
Date User Action Args
2018-02-27 00:00:00adminsetstatus: dr -> c++17
2017-02-06 00:00:00adminsetmessages: + msg6087
2017-02-06 00:00:00adminsetmessages: + msg6086
2017-02-06 00:00:00adminsetstatus: drafting -> dr
2015-11-10 00:00:00adminsetmessages: + msg5631
2014-03-03 00:00:00adminsetmessages: + msg4872
2013-05-03 00:00:00adminsetmessages: + msg4328
2011-08-12 00:00:00admincreate