子表达式求值顺序
我查看了 SO/IEC 9899:201x< J.1 下的 /a> 未指定行为:
"The order in which subexpressions are evaluated and the order in which side effects
take place, except as specified for the function-call (), &&, ||, ?:, and comma
operators (6.5)."
这是否意味着 in
func1() + func2();
func2() 可以在 func1() 之前执行,甚至可以在 func1() 期间执行?
I've looked at SO/IEC 9899:201x under J.1 Unspecified behavior:
"The order in which subexpressions are evaluated and the order in which side effects
take place, except as specified for the function-call (), &&, ||, ?:, and comma
operators (6.5)."
Does this means that in
func1() + func2();
func2() may be preformed before func1(), or even during func1() ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在当前标准 (ISO/IEC 9899:1999) 中,函数调用之间有一个序列点,但未指定
+
操作数的计算顺序,因此func1
可能在func2
之前或之后调用,但函数调用不得以任何方式重叠或交错。这意味着,如果需要,
func1
和func2
中的每一个都可以与某些共享数据进行交互,而不会以意外的方式更改其下的数据。In the current standard (ISO/IEC 9899:1999) there is a sequence point between function calls but the order of evaluation of the operands to
+
is not specified sofunc1
may be called before or afterfunc2
but the function calls must not overlap or be interleaved in any way.This means that each of
func1
andfunc2
can, if desired, interact with some shared data without having that data change under it in an unexpected way.不是期间,但肯定是,要么 1 然后 2,要么 2 然后 1。
Not during, but sure, either 1 then 2 or 2 then 1.