Title
Ranking of derived-to-base conversions should ignore reference binding
Status
open
Section
12.2.4.2.5 [over.ics.ref]
Submitter
Evan Girardin

Created on 2025-07-31.00:00:00 last changed 2 weeks ago

Messages

Date: 2025-08-16.21:03:13

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: ... ]
Date: 2025-07-31.00:00:00

(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.

History
Date User Action Args
2025-08-16 21:03:13adminsetmessages: + msg8081
2025-07-31 00:00:00admincreate