Skip to content

[over.ics.rank] Ranking of derived-to-base conversions should be agnostic to reference bindings #733

@t3nsor

Description

@t3nsor

Full name of submitter: Evan Girardin (he gave me permission to file this issue on his behalf)

Reference (section label): [over.ics.rank], [over.ics.ref]

Issue description: The tiebreaker rules in [over.ics.rank]/4 should apply to the case where one conversion has a reference as its destination type and the other does not. All known implementations agree. Therefore, [over.ics.ref] should be updated to specify the source and destination types for a derived-to-base reference binding.

Suggested resolution: Edit [over.ics.ref]/1:

When a parameter of type "reference to cv T" binds directly ([dcl.init.ref]) to an argument expression:

  • If the argument expression has a type that is a derived class of the parameter type, the implicit conversion sequence is a derived-to-base conversion from the class of the parameter type to T ([over.best.ics]).
  • Otherwise, if the type of the argument is possibly cv-qualified T, or if T is an array type of unknown bound with element type U and the argument has an array type of known bound whose element type is possibly cv-qualified U, the implicit conversion sequence is the identity conversion.
  • Otherwise, if T is a function type, the implicit conversion sequence is a function pointer conversion.
  • Otherwise, the implicit conversion sequence is a qualification conversion.

Strike subbullets 2 and 6 from [over.ics.rank]/4.5.

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: ...]
  • 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: ...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions