Skip to content

Commit 5c5570d

Browse files
jensmaurerzygoloid
authored andcommitted
[expr.add] Avoid x[i] syntax when defining pointer arithmetic.
1 parent 042e035 commit 5c5570d

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎source/expressions.tex‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5722,20 +5722,20 @@
57225722
\begin{itemize}
57235723
\item If \tcode{P} evaluates to a null pointer value and
57245724
\tcode{J} evaluates to 0, the result is a null pointer value.
5725-
\item Otherwise, if \tcode{P} points to element $\mathtt{x[}i\mathtt{]}$
5726-
of an array object \tcode{x} with $n$ elements,%
5725+
\item Otherwise, if \tcode{P} points to an array element $i$
5726+
of an array object \tcode{x} with $n$ elements\iref{dcl.array},%
57275727
\footnote{An object that is not an array element is considered to belong to a
57285728
single-element array for this purpose; see~\ref{expr.unary.op}.
57295729
A pointer past the last element of an array \tcode{x} of $n$ elements
5730-
is considered to be equivalent to a pointer to a hypothetical element
5731-
$\mathtt{x[}n\mathtt{]}$ for this purpose; see~\ref{basic.compound}.}
5730+
is considered to be equivalent to a pointer to a hypothetical array element
5731+
$n$ for this purpose; see~\ref{basic.compound}.}
57325732
the expressions \tcode{P + J} and \tcode{J + P}
57335733
(where \tcode{J} has the value $j$)
5734-
point to the (possibly-hypothetical) element
5735-
$\mathtt{x[}i + j\mathtt{]}$ if $0 \le i + j \le n$
5734+
point to the (possibly-hypothetical) array element
5735+
$i + j$ of \tcode{x} if $0 \le i + j \le n$
57365736
and the expression \tcode{P - J}
5737-
points to the (possibly-hypothetical) element
5738-
$\mathtt{x[}i - j\mathtt{]}$ if $0 \le i - j \le n$.
5737+
points to the (possibly-hypothetical) array element
5738+
$i - j$ of \tcode{x} if $0 \le i - j \le n$.
57395739
\item Otherwise, the behavior is undefined.
57405740
\end{itemize}
57415741

@@ -5754,7 +5754,7 @@
57545754
\item If \tcode{P} and \tcode{Q} both evaluate to null pointer values,
57555755
the result is 0.
57565756
\item Otherwise, if \tcode{P} and \tcode{Q} point to, respectively,
5757-
elements $\mathtt{x[}i\mathtt{]}$ and $\mathtt{x[}j\mathtt{]}$
5757+
array elements $i$ and $j$
57585758
of the same array object \tcode{x},
57595759
the expression \tcode{P - Q} has the value $i - j$.
57605760
\item Otherwise, the behavior is undefined.

0 commit comments

Comments
 (0)