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

2024-05-06


1827. Reference binding with ambiguous conversions

Section: 9.4.4  [dcl.init.ref]     Status: drafting     Submitter: Hubert Tong     Date: 2014-01-07

In the following case,

  struct A {
    operator int &&() const;
    operator int &&() volatile;
    operator long();
  };

  int main() {
    int &&x = A();
  }

the conversion for direct binding cannot be used because of the ambiguity, so indirect binding is used, which allows the use of the conversion to long in creating the temporary.

Is this intended? There is implementation variation.

Notes from the February, 2014 meeting:

CWG agreed that an ambiguity like this should make the initialization ill-formed instead of falling through to do indirect binding.