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

2024-11-11


2898. Clarify implicit conversion sequence from cv T to T

Section: 12.2.4.2.1  [over.best.ics.general]     Status: open     Submitter: Brian Bi     Date: 2024-05-30

(From submission #544.)

Subclause 12.2.4.2.1 [over.best.ics.general] paragraph 7 specifies:

When the parameter has a class type and the argument expression has the same type, the implicit conversion sequence is an identity conversion. When the parameter has a class type and the argument expression has a derived class type, the implicit conversion sequence is a derived-to-base conversion from the derived class to the base class. A derived-to-base conversion has Conversion rank (12.2.4.2.2 [over.ics.scs]).

Does "the same type" imply that differences in cv-qualification are significant? 12.2.4.2.1 [over.best.ics.general] paragraph 6 appears to differ:

... Any difference in top-level cv-qualification is subsumed by the initialization itself and does not constitute a conversion. [Example 2: A parameter of type A can be initialized from an argument of type const A. The implicit conversion sequence for that case is the identity sequence; it contains no "conversion" from const A to A. -- end example]

The example appears to reflect the intent; the normative wording should be clarified.

Suggested resolution:

  1. Change in 12.2.4.2.1 [over.best.ics.general] paragraph 6, moving the amended example to paragraph 7:

    ... Any difference in top-level cv-qualification is subsumed by the initialization itself and does not constitute a conversion. [Example 2: A parameter of type A can be initialized from an argument of type const A. The implicit conversion sequence for that case is the identity sequence; it contains no "conversion" from const A to A. -- end example]
  2. Change in 12.2.4.2.1 [over.best.ics.general] paragraph 7 as follows:

    When the parameter has a class type and the argument expression has the same type the cv-unqualified version of the type of the argument expression is the same as the parameter type, the implicit conversion sequence is an identity conversion. When the parameter has a class type and the argument expression has a (possibly cv-qualified) derived class type, the implicit conversion sequence is a derived-to-base conversion from the derived class to the base class. A derived-to-base conversion has Conversion rank (12.2.4.2.2 [over.ics.scs]). [Example: An implicit conversion sequence from an argument of type const A to a parameter of type A can be formed, even if overload resolution for copy-initialization of A from the argument would not find a viable function (12.2.2.4 [over.match.ctor], 12.2.3 [over.match.viable]). The implicit conversion sequence for that case is the identity sequence; it contains no "conversion" from const A to A. -- end example]