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

2025-09-28


3031. Finding declarations for conversion operators for access checking

Section: 12.2.2.1  [over.match.funcs.general]     Status: open     Submitter: Brian Bi     Date: 2025-03-29

Consider:

  class B {
    protected:
      operator int&() { static int x; return x; }
  };

  struct D : B { using B::operator int&; };

  int x = D();   // OK

The function B::operator int& is a candidate, but the using-declaration in D is not considered when checking accessibility, because name lookup is not actually performed.

Suggested resolution:

Change in 12.2.2.1 [over.match.funcs.general] paragraph 7 as follows:

In each case where conversion functions of a class S are considered for initializing an object or reference of type T, the candidate functions include the result of a search for the conversion-function-id operator T in S. [Note 3: This search can find a specialization of a conversion function template (6.5 [basic.lookup]). —end note] Each such case also defines sets of permissible types for explicit and non-explicit conversion functions; for each (non-template) conversion function F that is also a candidate function if looking up operator U in the scope of S succeeds and finds a declaration of F, that declaration is added to the candidate set. If initializing an object, for any permissible type cv U, any cv2 U, cv2 U&, or cv2 U&& is also a permissible type. If the set of permissible types for explicit conversion functions is empty, any candidates that are explicit are discarded.