<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2571</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="2571"></A><H4>2571.
  
Evaluation order for subscripting
</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>CD6
 &#160;&#160;&#160;

 <B>Submitter: </B>Corentin Jabot
 &#160;&#160;&#160;

 <B>Date: </B>2022-04-21<BR>


<P>[Accepted at the July, 2022 meeting.]</P>



<P>The specification about the relative sequencing of multiple
parameters of the subscripting operator is missing.  Also,
<A HREF="2507.html">issue 2507</A> adds support for default
arguments for user-defined subscripting operators, but the sequencing
of these is unspecified, too.</P>

<P><U>Suggested resolution: [SUPERSEDED]</U></P>

<P>Add a new paragraph 4 at the end of 7.6.1.2 [<A href="https://wg21.link/expr.sub">expr.sub</A>]:</P>

<BLOCKQUOTE>

<INS>If the subscript operator invokes an operator function, the
sequencing restrictions of the corresponding function call expression
apply (12.4.5 [<A href="https://wg21.link/over.sub">over.sub</A>],
7.6.1.3 [<A href="https://wg21.link/expr.call">expr.call</A>]).</INS>

</BLOCKQUOTE>

<P><B>Notes from the 2022-05-20 CWG telecon:</B></P>

<P>A wording approach amending 12.2.2.3 [<A href="https://wg21.link/over.match.oper#2">over.match.oper</A>] paragraph 2
instead would be preferred.</P>

<P><U>Possible resolution (2022-05-21): [SUPERSEDED]</U></P>

<P>Change in 12.2.2.3 [<A href="https://wg21.link/over.match.oper#2">over.match.oper</A>] paragraph 2 as follows:</P>

<BLOCKQUOTE>

Therefore, the operator notation is first transformed to the
equivalent function-call notation as summarized in Table 17 (where @
denotes one of the operators covered in the specified
subclause). However, <INS>except for the subscript operator
(7.6.1.2 [<A href="https://wg21.link/expr.sub">expr.sub</A>]),</INS> the operands are sequenced in
the order prescribed for the built-in operator
(7.6 [<A href="https://wg21.link/expr.compound">expr.compound</A>]).

</BLOCKQUOTE>

<P><B>Notes from the 2022-06-03 CWG telecon:</B></P>

<P>Repeating the function call rules for the subscript operator in
7.6.1.2 [<A href="https://wg21.link/expr.sub">expr.sub</A>] instead would be preferred, to
avoid any impression of a special case.</P>

<P><B>Proposed resolution (2022-06-24, amended 2022-07-15, approved by CWG 2022-07-15):</B></P>

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

<BLOCKQUOTE>

A <I>subscript expression</I> is a postfix expression followed by
square brackets containing a possibly empty, comma-separated list
of <I>initializer-clause</I>s <DEL>which</DEL> <INS>that</INS>
constitute the arguments to the subscript
operator. The <I>postfix-expression</I>
<INS>and the initialization of the object parameter of any applicable
subscript operator function</INS> is sequenced before each expression
in the <I>expression-list</I>
<INS>and also before any default argument.  The initialization of a
non-object parameter of a subscript operator function S
(12.4.5 [<A href="https://wg21.link/over.sub">over.sub</A>]), including every associated value
computation and side effect, is indeterminately sequenced with respect
to that of any other non-object parameter of S</INS>.
</BLOCKQUOTE>

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