Title
Temporaries and previously-initialized elements in aggregate initialization
Status
nad
Section
9.4.2 [dcl.init.aggr]
Submitter
Daveed Vandevoorde

Created on 2019-03-13.00:00:00 last changed 24 months ago

Messages

Date: 2019-07-15.00:00:00

Rationale (July, 2019)

The example is valid; the constant evaluation is the entire initialization constexpr A a1, thus the temporary bound to a1.temporary started its lifetime within the constant evaluation.

Date: 2019-03-13.00:00:00

There is implementation divergence with respect to an example like:

  constexpr int f(int &r) { r *= 9; return r - 12; }
  struct A { int &&temporary; int x; int y; };

  constexpr A a1 = { 6, f(a1.temporary), a1.temporary }; // #1 

Some implementations accept this code and others say that a1.temporary is not a constant expression in the initializer at #1.

History
Date User Action Args
2022-11-27 19:55:08adminsetmessages: + msg7065
2022-11-27 19:55:08adminsetstatus: open -> nad
2019-03-13 00:00:00admincreate