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

2024-10-26


2111. Array temporaries in reference binding

Section: 9.4.4  [dcl.init.ref]     Status: NAD     Submitter: Vinny Romano     Date: 2015-04-02

The current wording of the Standard appears to permit code like

  void f(const char (&)[10]);
  void g() {
    f("123");
    f({'a','b','c','\0'});
  }

creating a temporary array of ten elements and binding the parameter reference to it. This is controversial and should be reconsidered. (See issues 1058 and 1232.)

Rationale (March, 2016):

Whether to support creating a temporary array in such cases is a question of language design and thus should be considered by EWG.

EWG 2022-11-11

The intent is adequately expressed in the specification.