|
32 | 32 | expressions of class type~(Clause \ref{class}) or enumeration
|
33 | 33 | type~(\ref{dcl.enum}). Uses of overloaded operators are transformed into
|
34 | 34 | function calls as described in~\ref{over.oper}. Overloaded operators
|
35 |
| -obey the rules for syntax specified in Clause~\ref{expr}, but the |
36 |
| -requirements of operand type, value category, and evaluation order are replaced |
| 35 | +obey the rules for syntax and evaluation order specified in Clause~\ref{expr}, |
| 36 | +but the requirements of operand type and value category are replaced |
37 | 37 | by the rules for function call. Relations between operators, such as
|
38 | 38 | \tcode{++a} meaning \tcode{a+=1}, are not guaranteed for overloaded
|
39 | 39 | operators~(\ref{over.oper}).
|
|
1461 | 1461 | \tcode{+} and~\ref{dcl.array} for details of arrays.
|
1462 | 1462 | \end{note}, except that in the case of an array operand, the result is an lvalue
|
1463 | 1463 | if that operand is an lvalue and an xvalue otherwise.
|
| 1464 | +The expression \tcode{E1} is sequenced before the expression \tcode{E2}. |
1464 | 1465 |
|
1465 | 1466 | \pnum
|
1466 | 1467 | A \grammarterm{braced-init-list} shall not be used with the built-in subscript operator.
|
|
1538 | 1539 | When a function is called, each parameter~(\ref{dcl.fct}) shall be
|
1539 | 1540 | initialized~(\ref{dcl.init},~\ref{class.copy},~\ref{class.ctor}) with
|
1540 | 1541 | its corresponding argument.
|
1541 |
| -\begin{note} Such initializations are indeterminately sequenced |
1542 |
| -with respect to each other~(\ref{intro.execution}) \end{note} |
1543 | 1542 | If the function is a non-static member
|
1544 | 1543 | function, the \tcode{this} parameter of the function~(\ref{class.this})
|
1545 | 1544 | shall be initialized with a pointer to the object of the call, converted
|
|
1573 | 1572 | (Clause~\ref{except}) with a handler that could handle the exception,
|
1574 | 1573 | this handler is not considered.
|
1575 | 1574 | \end{example}
|
| 1575 | + |
| 1576 | +\pnum |
| 1577 | +\indextext{evaluation!order~of argument}% |
| 1578 | +\indextext{evaluation!unspecified order~of function~call}% |
| 1579 | +\indextext{evaluation!unspecified order~of argument}% |
| 1580 | +The \grammarterm{postfix-expression} is sequenced before |
| 1581 | +each \grammarterm{expression} in the \grammarterm{expression-list} |
| 1582 | +and any default argument. |
| 1583 | +The initialization of a parameter, |
| 1584 | +including every associated value computation and side effect, |
| 1585 | +is indeterminately sequenced with respect to that of any other parameter. |
| 1586 | +\begin{note} |
| 1587 | +All side effects of |
| 1588 | +argument evaluations are sequenced before the function is |
| 1589 | +entered (see~\ref{intro.execution}). |
| 1590 | +\end{note} |
| 1591 | +\begin{example} |
| 1592 | +\begin{codeblock} |
| 1593 | +void f() { |
| 1594 | + std::string s = "but I have heard it works even if you don't believe in it"; |
| 1595 | + s.replace(0, 4, "").replace(s.find("even"), 4, "only").replace(s.find(" don't"), 6, ""); |
| 1596 | + assert(s == "I have heard it works only if you believe in it"); // OK |
| 1597 | +} |
| 1598 | +\end{codeblock} |
| 1599 | +\end{example} |
| 1600 | + |
| 1601 | +\pnum |
1576 | 1602 | The result of a function call is the
|
1577 | 1603 | result of the operand of the evaluated \tcode{return} statement~(\ref{stmt.return})
|
1578 | 1604 | in the called function (if any),
|
|
1642 | 1668 | promoted type before the call. These promotions are referred to as
|
1643 | 1669 | the \defnx{default argument promotions}{promotion!default argument promotion}.
|
1644 | 1670 |
|
1645 |
| -\pnum |
1646 |
| -\indextext{evaluation!order~of argument}% |
1647 |
| -\indextext{evaluation!unspecified order~of function~call}% |
1648 |
| -\begin{note} |
1649 |
| -The evaluations of the postfix expression and of the arguments |
1650 |
| -are all unsequenced relative to one another. |
1651 |
| -\indextext{evaluation!unspecified order~of argument}% |
1652 |
| -All side effects of |
1653 |
| -argument evaluations are sequenced before the function is |
1654 |
| -entered (see~\ref{intro.execution}). |
1655 |
| -\end{note} |
1656 |
| - |
1657 | 1671 | \pnum
|
1658 | 1672 | \indextext{function~call!recursive}%
|
1659 | 1673 | Recursive calls are permitted, except to the \tcode{main}
|
|
3393 | 3407 | \pnum
|
3394 | 3408 | \indextext{\idxcode{new}!unspecified order~of evaluation}%
|
3395 | 3409 | \indextext{\idxcode{new}!unspecified constructor~and}%
|
3396 |
| -The invocation of the allocation function is indeterminately sequenced with respect to |
| 3410 | +The invocation of the allocation function is sequenced before |
3397 | 3411 | the evaluations of expressions in the \grammarterm{new-initializer}. Initialization of
|
3398 | 3412 | the allocated object is sequenced before the
|
3399 | 3413 | \indextext{value computation}%
|
3400 | 3414 | value computation of the
|
3401 | 3415 | \grammarterm{new-expression}.
|
3402 |
| -\indextext{constructor!unspecified argument~to}% |
3403 |
| -It is unspecified whether expressions in the \grammarterm{new-initializer} are |
3404 |
| -evaluated if the allocation function returns the null pointer or exits |
3405 |
| -using an exception. |
3406 | 3416 |
|
3407 | 3417 | \pnum
|
3408 | 3418 | If the \grammarterm{new-expression} creates an object or an array of
|
|
3417 | 3427 | If any part of the object initialization described above\footnote{This may
|
3418 | 3428 | include evaluating a \grammarterm{new-initializer} and/or calling
|
3419 | 3429 | a constructor.}
|
3420 |
| -terminates by throwing an exception, storage has been obtained for the |
3421 |
| -object, and a suitable deallocation function |
| 3430 | +terminates by throwing an exception and a suitable deallocation function |
3422 | 3431 | can be found, the deallocation function is called to free the memory in
|
3423 | 3432 | which the object was being constructed, after which the exception
|
3424 | 3433 | continues to propagate in the context of the \grammarterm{new-expression}.
|
|
3871 | 3880 | If the dynamic type of \tcode{E1} does not
|
3872 | 3881 | contain the member to which
|
3873 | 3882 | \tcode{E2} refers, the behavior is undefined.
|
| 3883 | +Otherwise, the expression \tcode{E1} is sequenced before the expression \tcode{E2}. |
3874 | 3884 |
|
3875 | 3885 | \pnum
|
3876 | 3886 | The restrictions on \cvqual{cv-}qualification, and the manner in which
|
|
4125 | 4135 | has a signed type and a negative value, the resulting value is
|
4126 | 4136 | \impldef{result of right shift of negative value}.
|
4127 | 4137 |
|
| 4138 | +\pnum |
| 4139 | +The expression \tcode{E1} is sequenced before the expression \tcode{E2}. |
| 4140 | + |
4128 | 4141 | \rSec1[expr.rel]{Relational operators}%
|
4129 | 4142 | \indextext{expression!relational operators}%
|
4130 | 4143 | \indextext{operator!relational}
|
|
4685 | 4698 | \indextext{value computation}%
|
4686 | 4699 | value computation of the right and left operands,
|
4687 | 4700 | and before the
|
4688 |
| -value computation of the assignment expression. With |
| 4701 | +value computation of the assignment expression. |
| 4702 | +The right operand is sequenced before the left operand. |
| 4703 | +With |
4689 | 4704 | respect to an indeterminately-sequenced function call, the operation of
|
4690 | 4705 | a compound assignment is a single evaluation.
|
4691 | 4706 | \begin{note}
|
|
4795 | 4810 |
|
4796 | 4811 | A pair of expressions separated by a comma is evaluated left-to-right;
|
4797 | 4812 | the left expression is
|
4798 |
| -a discarded-value expression (Clause~\ref{expr}).\footnote{However, an |
4799 |
| -invocation of an overloaded comma operator is an ordinary function call; hence, |
4800 |
| -the evaluations of its argument expressions are unsequenced relative to one |
4801 |
| -another~(see \ref{intro.execution}).} |
| 4813 | +a discarded-value expression (Clause~\ref{expr}). |
4802 | 4814 | Every
|
4803 | 4815 | \indextext{value computation}%
|
4804 | 4816 | value computation and side effect
|
|
0 commit comments