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

2024-12-06


1571. cv-qualification for indirect reference binding via conversion function

Section: 9.4.4  [dcl.init.ref]     Status: CD4     Submitter: Michael Wong     Date: 2012-02-06

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

In the case of indirect reference binding, 9.4.4 [dcl.init.ref] paragraph 5 only requires that the cv-qualification of the referred-to type be the same or greater than that of the initializer expression when the types are reference-related. This leads to the following anomaly:

  class A {
  public:
    operator volatile int &();
  };
  A a;

  const int & ir1a = a.operator volatile int&(); // error!
  const int & ir2a = a; // allowed! ir = a.operator volatile int&();

Is this intended?

Notes from the April, 2013 meeting:

CWG felt that the declaration of ir2a should also be an error.

Proposed resolution (February, 2014):

Change 9.4.4 [dcl.init.ref] paragraph 5 as follows:

A reference to type “cv1 T1” is initialized by an expression of type “cv2 T2” as follows:

This resolution also resolves issue 1572.