You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int a[2][3] = {{0,1,2},{3,4,5}};
int i = 0;
auto r = a[i++][i++];
[expr.sub] p1 says
The postfix-expression and the initialization of the object parameter of any applicable subscript operator function is sequenced before each expression in the expression-list and also before any default argument.
In this example, a is sequenced before the first i++, and the a[i++] is sequenced before the second i++. [intro.execution] p8 says
An expression X is said to be sequenced before an expression Y if every value computation and every side effect associated with the expression X is sequenced before every value computation and every side effect associated with the expression Y.
Do these two rules guarantee the side effect of the first i++(which is the subexpression of a[i++]) is sequenced before the value computation of the second i++? The meaning of the "associated with" is not clear enough here.
Improvement
An expression X is said to be sequenced before an expression Y if every value computation and every side effect associated with the expression X is sequenced before every value computation and every side effect associated with the expression Y (including these of the subexpressions thereof, if any).
With this improvement, the side effect of the subexpressions is ascribed to the evaluation of the post-expression.
The text was updated successfully, but these errors were encountered:
Consider this example
[expr.sub] p1 says
In this example,
a
is sequenced before the firsti++
, and thea[i++]
is sequenced before the secondi++
. [intro.execution] p8 saysDo these two rules guarantee the side effect of the first
i++
(which is the subexpression ofa[i++]
) is sequenced before the value computation of the secondi++
? The meaning of the "associated with" is not clear enough here.Improvement
With this improvement, the side effect of the subexpressions is ascribed to the evaluation of the post-expression.
The text was updated successfully, but these errors were encountered: