Parenthesized initialization of reference-to-aggregate
9.4.1 [dcl.init.general]
Mike Miller

Created on 2023-03-14.00:00:00 last changed 2 weeks ago


Date: 2023-03-15.00:00:00

Additional notes (March, 2023)

Forwarded to EWG for consideration via cplusplus/papers#1494 by decision of the CWG chair.

Date: 2023-03-19.19:31:47

Paper P0960R3 enabled initialization of aggregates (including arrays) from parenthesized expression lists. The rather similar case of initializating a reference to an aggregate was not addressed. For example:

  const int (&ra)[2](1,2);

There is no evidence in 9.4.1 [dcl.init.general] paragraph 16 that such support is intended, nor does 9.4.4 [dcl.init.ref] paragraph 5 admit an initializer other than a (single) expression for a reference.

There is implementation divergence: gcc accepts, others reject. Also, the parenthesized aggregate initialization paper P0960R3 apparently originally envisioned a textual transformation to a braced-init-list, which presumably would have permitted the example. It is not clear whether the reference case was intentionally or accidentially dropped during the multiple revisions of the paper.

Date User Action Args
2023-03-16 23:18:20adminsetmessages: + msg7233
2023-03-14 00:00:00admincreate