函数参数:不确定顺序还是无顺序?
Function parameters: intedeterminately sequenced or unsequenced?
在 cppreference 我看到以下文字:
In a function call, value computations and side effects of the initialization of every parameter are indeterminately sequenced with respect to value computations and side effects of any other parameter.
然而,我无法在 C++17 标准中找到任何对此的确认。
函数参数作为子表达式,应符合[intro.execution.17]:
Except where noted, evaluations of operands of individual operators and of subexpressions of individual
expressions are unsequenced. [ Note: In an expression that is evaluated more than once during the execution
of a program, unsequenced and indeterminately sequenced evaluations of its subexpressions need not be
performed consistently in different evaluations. — end note ] The value computations of the operands of
an operator are sequenced before the value computation of the result of the operator. If a side effect on a
memory location (4.4) is unsequenced relative to either another side effect on the same memory location or a
value computation using the value of any object in the same memory location, and they are not potentially
concurrent (4.7), the behavior is undefined. [ Note: The next section imposes similar, but more complex
restrictions on potentially concurrent computations. — end note ]
这意味着,除非标准中的任何其他点禁止,否则函数参数计算应该是无序的。我试图在标准文本中找到子字符串 "indeterminately",出现 10 次的 none 看起来与函数调用参数相关。
所以,问题是:函数参数在 C++17 中是无序的还是不确定的?
[expr.call]/5 The postfix-expression is sequenced before each expression in the expression-list and any default argument. The initialization of a parameter, including every associated value computation and side effect, is indeterminately sequenced with respect to that of any other parameter.
强调我的。
在 cppreference 我看到以下文字:
In a function call, value computations and side effects of the initialization of every parameter are indeterminately sequenced with respect to value computations and side effects of any other parameter.
然而,我无法在 C++17 标准中找到任何对此的确认。
函数参数作为子表达式,应符合[intro.execution.17]:
Except where noted, evaluations of operands of individual operators and of subexpressions of individual expressions are unsequenced. [ Note: In an expression that is evaluated more than once during the execution of a program, unsequenced and indeterminately sequenced evaluations of its subexpressions need not be performed consistently in different evaluations. — end note ] The value computations of the operands of an operator are sequenced before the value computation of the result of the operator. If a side effect on a memory location (4.4) is unsequenced relative to either another side effect on the same memory location or a value computation using the value of any object in the same memory location, and they are not potentially concurrent (4.7), the behavior is undefined. [ Note: The next section imposes similar, but more complex restrictions on potentially concurrent computations. — end note ]
这意味着,除非标准中的任何其他点禁止,否则函数参数计算应该是无序的。我试图在标准文本中找到子字符串 "indeterminately",出现 10 次的 none 看起来与函数调用参数相关。
所以,问题是:函数参数在 C++17 中是无序的还是不确定的?
[expr.call]/5 The postfix-expression is sequenced before each expression in the expression-list and any default argument. The initialization of a parameter, including every associated value computation and side effect, is indeterminately sequenced with respect to that of any other parameter.
强调我的。