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

2024-04-18


2128. Imprecise rule for reference member initializer

Section: 9.4.2  [dcl.init.aggr]     Status: drafting     Submitter: Richard Smith     Date: 2015-05-19

According to 11.9.3 [class.base.init] paragraph 11,

A temporary expression bound to a reference member from a brace-or-equal-initializer is ill-formed. [Example:

  struct A {
    A() = default;          // OK
    A(int v) : v(v) { }     // OK
    const int& v = 42;      // OK
  };
  A a1;                     // error: ill-formed binding of temporary to reference
  A a2(1);                  // OK, unfortunately

end example]

The rule is intended to apply only if an actual initialization results in such a binding, but it could be read as applying to the declaration of A::v itself. It would be clearer if the restriction were moved into bullet 9.1, e.g.,