Skip to content

Commit a207869

Browse files
authored
Merge 2019-07 CWG Motion 2
P1161R3 Deprecate uses of the comma operator in subscripting expressions Fixes #2981.
2 parents ea2c699 + 9fdd8bc commit a207869

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

source/expressions.tex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,6 +2862,14 @@
28622862
if that operand is an lvalue and an xvalue otherwise.
28632863
The expression \tcode{E1} is sequenced before the expression \tcode{E2}.
28642864

2865+
\pnum
2866+
\begin{note}
2867+
A comma expression\iref{expr.comma}
2868+
appearing as the \grammarterm{expr-or-braced-init-list}
2869+
of a subscripting expression is deprecated;
2870+
see \ref{depr.comma.subscript}.
2871+
\end{note}
2872+
28652873
\pnum
28662874
\begin{note}
28672875
Despite its asymmetric appearance, subscripting is a commutative
@@ -6793,6 +6801,14 @@
67936801
\tcode{5}.
67946802
\end{example}
67956803

6804+
\pnum
6805+
\begin{note}
6806+
A comma expression
6807+
appearing as the \grammarterm{expr-or-braced-init-list}
6808+
of a subscripting expression\iref{expr.sub} is deprecated;
6809+
see \ref{depr.comma.subscript}.
6810+
\end{note}
6811+
67966812
\rSec1[expr.const]{Constant expressions}%
67976813
\indextext{expression!constant}
67986814

source/future.tex

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@
5454
\end{codeblock}
5555
\end{example}
5656

57+
\rSec1[depr.comma.subscript]{Comma operator in subscript expressions}
58+
59+
\pnum
60+
A comma expression\iref{expr.comma}
61+
appearing as the \grammarterm{expr-or-braced-init-list}
62+
of a subscripting expression\iref{expr.sub} is deprecated.
63+
\begin{note}
64+
A parenthesized comma expression is not deprecated.
65+
\end{note}
66+
\begin{example}
67+
\begin{codeblock}
68+
void f(int *a, int b, int c) {
69+
a[b,c]; // deprecated
70+
a[(b,c)]; // OK
71+
}
72+
\end{codeblock}
73+
\end{example}
74+
5775
\rSec1[depr.array.comp]{Array comparisons}
5876

5977
\pnum

0 commit comments

Comments
 (0)