<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 799</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="799"></A><H4>799.
  
Can <TT>reinterpret_cast</TT> be used to cast an operand to its own type?
</H4>
<B>Section: </B>7.6.1.10&#160; [<A href="https://wg21.link/expr.reinterpret.cast">expr.reinterpret.cast</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD2
 &#160;&#160;&#160;

 <B>Submitter: </B>UK
 &#160;&#160;&#160;

 <B>Date: </B>3 March, 2009<BR><BR>


<A href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3086.html#UK55">N2800 comment
  UK&#160;55<BR></A>

<P>[Voted into WP at March, 2010 meeting.]</P>

<P>The note in 7.6.1.10 [<A href="https://wg21.link/expr.reinterpret.cast#2">expr.reinterpret.cast</A>] paragraph 2 says,</P>

<BLOCKQUOTE>

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

</BLOCKQUOTE>

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

<P>(See also <A HREF="944.html">issue 944</A>.)</P>

<P><B>Proposed resolution (October, 2009):</B></P>

<OL>
<LI><P>Change 7.6.1.10 [<A href="https://wg21.link/expr.reinterpret.cast#2">expr.reinterpret.cast</A>] paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

The <TT>reinterpret_cast</TT> operator shall not cast away constness
(7.6.1.11 [<A href="https://wg21.link/expr.const.cast">expr.const.cast</A>]).  <DEL>[<I>Note:</I> Subject to the
restrictions in this section, an expression may be cast to its own
type using a <TT>reinterpret_cast</TT> operator. &#8212;<I>end
note</I>]</DEL> <INS>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.</INS>

</BLOCKQUOTE>

<LI><P>Change 7.6.1.10 [<A href="https://wg21.link/expr.reinterpret.cast#10">expr.reinterpret.cast</A>] paragraph 10 as follows:</P></LI>

<BLOCKQUOTE>

An rvalue of type &#8220;pointer to member of <TT>X</TT> of type
<TT>T1</TT>&#8221; can be explicitly converted to an rvalue of <INS>a
different</INS> type &#8220;pointer to member of <TT>Y</TT> of type
<TT>T2</TT>&#8221; if <TT>T1</TT> and <TT>T2</TT> are both function
types or both object types...

</BLOCKQUOTE>

</OL>

<BR><BR>
</BODY>
</HTML>
