Title
Similar types and reference compatibility
Status
cd3
Section
9.4.4 [dcl.init.ref]
Submitter
Daniel Krügler

Created on 2011-10-03.00:00:00 last changed 123 months ago

Messages

Date: 2012-10-15.00:00:00

[Moved to DR at the October, 2012 meeting.]

Date: 2012-02-15.00:00:00

Proposed resolution (February, 2012):

  1. Change 9.4.4 [dcl.init.ref] paragraph 4 as follows:

  2. Given types “cv1 T1” and “cv2 T2,” “cv1 T1” is reference-related to “cv2 T2” if T1 is the same type as T2, or T1 is a base class of T2. “cv1 T1” is reference-compatible with “cv2 T2” if T1 is reference-related to T2 and cv1 is the same cv-qualification as, or greater cv-qualification than, cv2. For purposes of overload resolution, cases for which cv1 is greater cv-qualification than cv2 are identified as reference-compatible with added qualification (see 12.2.4.3 [over.ics.rank]). In all cases...
  3. Delete 12.2.4.2.5 [over.ics.ref] paragraph 5:

  4. The binding of a reference to an expression that is reference-compatible with added qualification influences the rank of a standard conversion; see 12.2.4.3 [over.ics.rank] and 9.4.4 [dcl.init.ref].

    [Drafting note: CWG decided not to make a substantive change for this issue, but the investigation discovered that the term defined by these two citations is not actually used and could be removed.]

Date: 2011-10-03.00:00:00

The definition of reference-compatible types in 9.4.4 [dcl.init.ref] paragraph 4 allows the types to differ in top-level cv-qualification, but it does not encompass the deeper added cv-qualification permitted for “similar types” (7.3.6 [conv.qual]). This seems surprising and could lead to errors resulting from the fact that the reference will be bound to a temporary and not to the original object in the initializer.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-05-03 00:00:00adminsetstatus: dr -> drwp
2012-11-03 00:00:00adminsetmessages: + msg4146
2012-11-03 00:00:00adminsetstatus: ready -> dr
2012-02-27 00:00:00adminsetmessages: + msg3722
2012-02-27 00:00:00adminsetstatus: open -> ready
2011-10-03 00:00:00admincreate