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

2024-03-20


1758. Explicit conversion in copy/move list initialization

Section: 12.2.2.8  [over.match.list]     Status: CD4     Submitter: Richard Smith     Date: 2013-09-21

[Moved to DR at the November, 2014 meeting.]

Consider the following example:

  struct X { X(); };
  struct Y { explicit operator X(); } y;
  X x{y};

This appears to be ill-formed, although the corresponding case with parentheses is well-formed. There seem to be two factors that prevent this from being accepted:

First, the special provision allowing an explicit conversion function to be used when initializing the parameter of a copy/move constructor is in 12.2.2.5 [over.match.copy], and this case takes us to 12.2.2.8 [over.match.list] instead.

Second, 12.2.4.2 [over.best.ics] paragraph 4 says that in this case, because we are in 12.2.2.8 [over.match.list], and we have a single argument, and we are calling a copy/move constructor, we are not allowed to consider a user-defined conversion sequence for the argument.

Similarly, in an example like

  struct A {
   A() {}
   A(const A &) {}
  };
  struct B {
   operator A() { return A(); }
  } b;
  A a{b};

the wording in 12.2.4.2 [over.best.ics] paragraph 4 with regard to 12.2.2.8 [over.match.list] prevents considering B's conversion function when initializing the first parameter of A's copy constructor, thereby making this code ill-formed.

Notes from the February, 2014 meeting:

This issue should be addressed by the eventual resolution of issue 1467.

Proposed resolution (June, 2014):

This issue is resolved by the resolution of issue 1467.