Movatterモバイル変換


[0]ホーム

URL:


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

2025-12-20


1343. Sequencing of non-class initialization

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

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

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

Additional note, April, 2013:

There is implementation variance in the treatment of thefollowing 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 onefull-expression, so the limitation above to “initializationof 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 10requires the temporary for5 to persist until theinitialization ofy is complete.

Proposed resolution (June, 2016):

The resolution is given in paper P0507R0.




[8]ページ先頭

©2009-2026 Movatter.jp