Title
Initialization should ignore the destination type's cv-qualification
Status
dr
Section
9.4.1 [dcl.init.general]
Submitter
Brian Bi

Created on 2024-05-29.00:00:00 last changed 4 months ago

Messages

Date: 2024-06-14.20:31:51

Proposed resolution (approved by CWG 2024-06-14):

  1. Change in 9.4.1 [dcl.init.general] paragraph 16 as follows:

    The semantics of initializers are as follows. The destination type is the cv-unqualified type of the object or reference being initialized and the source type is the type of the initializer expression. If the initializer is not a single (possibly parenthesized) expression, the source type is not defined.
  2. Change in 9.4.1 [dcl.init.general] bullet 16.6 as follows:

    • Otherwise, if the destination type is a (possibly cv-qualified) class type:
      • If the initializer expression is a prvalue and the cv-unqualified version of the source type is the same class as the class of as the destination type, the initializer expression is used to initialize the destination object. [Example 2: T x = T(T(T())); value-initializes x. —end example]
      • Otherwise, if the initialization is direct-initialization, or if it is copy-initialization where the cv-unqualified version of the source type is the same class as, or a derived class of, the class of as or is derived from the destination type, constructors are considered. The applicable constructors are enumerated (12.2.2.4 [over.match.ctor]), and the best one is chosen through overload resolution (12.2 [over.match]). Then:
  3. Change in 9.4.1 [dcl.init.general] bullet 16.9 as follows:

    • Otherwise, the initial value of the object being initialized is the (possibly converted) value of the initializer expression. A standard conversion sequence (7.3 [conv]) is used to convert the initializer expression to a prvalue of the cv-unqualified version of the destination type; no user-defined conversions are considered. If the conversion cannot be done, the initialization is ill-formed. When initializing a bit-field with a value that it cannot represent, the resulting value of the bit-field is implementation-defined. [ Note: ... ]
Date: 2024-06-15.00:00:00

[Accepted as a DR at the June, 2024 meeting.]

(From submission #541.)

Initialization of cv T follows the same rules as initialization of T. Issue 2830 clarified this for list-initialization. Further amendments are needed to properly handle cv-qualified versions of char8_t and char16_t as well as bool.

History
Date User Action Args
2024-07-20 13:52:34adminsetstatus: ready -> dr
2024-06-27 04:25:11adminsetstatus: tentatively ready -> ready
2024-06-14 20:31:51adminsetstatus: open -> tentatively ready
2024-05-30 22:19:05adminsetmessages: + msg7712
2024-05-29 00:00:00admincreate