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


3057. Ranking of derived-to-base conversions should ignore reference binding

Section: 12.2.4.2.5  [over.ics.ref]     Status: open     Submitter: Evan Girardin     Date: 2025-07-31

(From submission #733.)

The derived-to-base tiebreaker rules in 12.2.4.3 [over.ics.rank] paragraph 4 should apply regardless of whether one destination type is a reference and the other one is not. Major implementations agree.

Suggested resolution:

  1. Change in 12.2.4.2.5 [over.ics.ref] paragraph 1 as follows:

    When a parameter of type “reference to cv T” binds directly (9.5.4 [dcl.init.ref]) to an argument expression:
    • If the argument expression has a type D that is a derived class of the parameter type T, the implicit conversion sequence is a derived-to-base conversion from D to T (12.2.4.2 [over.best.ics]).
    • ...
  2. Change in 12.2.4.3 [over.ics.rank] bullet 4.5 as follows:

    • ...
    • If class B is derived directly or indirectly from class A and class C is derived directly or indirectly from B,
      • conversion of C* to B* is better than conversion of C* to A*, [Example 10: ... —end example]
      • binding of an expression of type C to a reference to type B is better than binding an expression of type C to a reference to type A,
      • conversion of A::* to B::* is better than conversion of A::* to C::*,
      • conversion of C to B is better than conversion of C to A,
      • conversion of B* to A* is better than conversion of C* to A*,
      • binding of an expression of type B to a reference to type A is better than binding an expression of type C to a reference to type A,
      • conversion of B::* to C::* is better than conversion of A::* to C::*, and
      • conversion of B to A is better than conversion of C to A.
      [ Note: ... ]