c++ - 函数参数 : intedeterminately sequenced or unsequenced?

标签 c++ language-lawyer c++17 function-parameter sequence-points

<分区>

关于 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 ]

这意味着,除非标准中的任何其他点禁止,否则函数参数计算应该是无序的。我试图在标准文本中“不确定地”找到一个子字符串,但 10 次出现看起来都与函数调用参数无关。

因此,问题是: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.

强调我的。

关于c++ - 函数参数 : intedeterminately sequenced or unsequenced?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50645602/

相关文章:

c++ - 基于位置的包中的特定类型

c++ - 在 C/C++ 中,是否保证 volatile 变量在线程之间具有最终一致的语义?

c++ - 带有抽象类的列表与 vector

c++ - Windows map 文件系统

c++ - 如何将此 VC++ 6 代码转换为 VC++ 2008?

c++ - 使用 std::initializer_list 的 constexpr 的奇怪行为

c++ - 大小小于 int 的位域是否应该作为整体提升的主题?

c++ - 如何返回 std::optional lambda?

c++ - 创建类的对象时函数调用的顺序

c++ - 通过将其分配给 const std::tuple<int, int>& 来延长 std::tuple<int&,int> 的生命周期