<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1652</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="1652"></A><H4>1652.
  
Object addresses in <TT>constexpr</TT> expressions
</H4>
<B>Section: </B>7.6.10&#160; [<A href="https://wg21.link/expr.eq">expr.eq</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Richard Smith
 &#160;&#160;&#160;

 <B>Date: </B>2013-04-15<BR>


<P>[Moved to DR at the May, 2015 meeting.]</P>

<P>Pointer equality is defined by reference to the addresses of the
objects designated by the pointer values, reflecting the implementation
technique of most/all compilers.  However, this definition is intrinsically
a runtime property, and such a description is inappropriate with respect to
<TT>constexpr</TT> expressions, which must deal with pointer comparisons
without necessarily knowing the runtime layout of the objects involved.  A
better definition usable at compile time is needed.</P>

<P><B>Proposed resolution (November, 2014):</B></P>

<P>Change 7.6.10 [<A href="https://wg21.link/expr.eq#2">expr.eq</A>] paragraph 2, converting
the existing running text into bullets, as follows:</P>

<BLOCKQUOTE>

<P>If at least one of the operands is a pointer, pointer
conversions (7.3.12 [<A href="https://wg21.link/conv.ptr">conv.ptr</A>]) and qualification
conversions (7.3.6 [<A href="https://wg21.link/conv.qual">conv.qual</A>]) are performed on both
operands to bring them to their composite pointer type
(Clause 7 [<A href="https://wg21.link/expr">expr</A>]). Comparing pointers is
defined as follows: <DEL>Two pointers compare equal</DEL>
</P>

<UL>
<LI><P><INS>If one pointer represents the address of a
complete object, and another pointer represents the address
one past the last element of a different complete object
[<I>Footnote:</I> An object that is not an array element is
considered to belong to a single-element array for this
purpose; see 7.6.2.2 [<A href="https://wg21.link/expr.unary.op">expr.unary.op</A>]. &#8212;<I>end
footnote</I>], the result of the comparison is
unspecified.</INS></P></LI>

<LI><P>
<INS>Otherwise,</INS> if <DEL>they</DEL> <INS>the
pointers</INS> are both null, both point to the same function,
or both represent the same address (6.9.4 [<A href="https://wg21.link/basic.compound">basic.compound</A>]),
<INS>they compare equal.</INS>
</P></LI>

<LI><P>
<DEL>otherwise they</DEL> <INS>Otherwise, the
pointers</INS> compare unequal.</P></LI>

</UL>

</BLOCKQUOTE>

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