<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1213</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="1213"></A><H4>1213.
  
Array subscripting and xvalues
</H4>
<B>Section: </B>7.6.1.2&#160; [<A href="https://wg21.link/expr.sub">expr.sub</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>2010-10-24<BR>


<P>[Moved to DR status at the April, 2013 meeting.]</P>



<P>Because the subscripting operation is defined as indirection through
a pointer value, the result of a subscript operator applied to an
xvalue array is an lvalue, not an xvalue.  This could be surprising to
some.</P>

<P><B>Proposed resolution (December, 2012):</B></P>

<P>Change 7.6.1.2 [<A href="https://wg21.link/expr.sub#1">expr.sub</A>] paragraph 1 as follows:</P>

<BLOCKQUOTE>

A postfix expression followed by an expression in square brackets is a
postfix expression. One of the expressions shall have the type
<INS>&#8220;array of <TT>T</TT>&#8221; or</INS>
&#8220;pointer to T&#8221; and the other shall have unscoped
enumeration or integral type.  The result is <DEL>an lvalue</DEL> of type
&#8220;<TT>T</TT>.&#8221; The type &#8220;<TT>T</TT>&#8221; shall be a
completely-defined object type.<SUP>62</SUP> The expression
<TT>E1[E2]</TT> is identical (by definition) to <TT>*((E1)+(E2))</TT>
[<I>Note:</I> see 7.6.2 [<A href="https://wg21.link/expr.unary">expr.unary</A>] and 7.6.6 [<A href="https://wg21.link/expr.add">expr.add</A>] for details of <TT>*</TT> and <TT>+</TT> and 9.3.4.5 [<A href="https://wg21.link/dcl.array">dcl.array</A>] for details of arrays.  &#8212;<I>end note</I>]<INS>,
except that in the case of an array operand, the result is an lvalue if
that operand is an lvalue and an xvalue otherwise.</INS>

</BLOCKQUOTE>

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

<P><B>Additional note (January, 2013):</B></P>

<P>The preceding resolution differs from that discussed in the
December, 2012 drafting review teleconference by the deletion of the
words &#8220;an lvalue&#8221; in the second sentence.  The issue has
consequently been moved to "review" status instead of "tentatively
ready."</P>

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