Title
Can reinterpret_cast be used to cast an operand to its own type?
Status
cd2
Section
7.6.1.10 [expr.reinterpret.cast]
Submitter
UK

Created on 2009-03-03.00:00:00 last changed 178 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting.]

Date: 2009-10-15.00:00:00

Proposed resolution (October, 2009):

  1. Change 7.6.1.10 [expr.reinterpret.cast] paragraph 2 as follows:

  2. The reinterpret_cast operator shall not cast away constness (7.6.1.11 [expr.const.cast]). [Note: Subject to the restrictions in this section, an expression may be cast to its own type using a reinterpret_cast operator. —end note] An expression of integral, enumeration, pointer, or pointer-to-member type can be explictly converted to its own type; such a cast yields the value of its operand.
  3. Change 7.6.1.10 [expr.reinterpret.cast] paragraph 10 as follows:

  4. An rvalue of type “pointer to member of X of type T1” can be explicitly converted to an rvalue of a different type “pointer to member of Y of type T2” if T1 and T2 are both function types or both object types...
Date: 2009-11-08.00:00:00
N2800 comment UK 55

The note in 7.6.1.10 [expr.reinterpret.cast] paragraph 2 says,

Subject to the restrictions in this section, an expression may be cast to its own type using a reinterpret_cast operator.

However, there is nothing in the normative text that permits this conversion, and paragraph 1 forbids any conversion not explicitly permitted.

(See also issue 944.)

History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2676
2010-03-29 00:00:00adminsetstatus: ready -> cd2
2009-08-03 00:00:00adminsetmessages: + msg2146
2009-08-03 00:00:00adminsetstatus: open -> ready
2009-03-03 00:00:00admincreate