子表达式求值顺序

发布于 2024-08-11 12:48:58 字数 485 浏览 1 评论 0原文

我查看了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忆沫 2024-08-18 12:48:58

在当前标准 (ISO/IEC 9899:1999) 中,函数调用之间有一个序列点,但未指定 + 操作数的计算顺序,因此 func1 可能在 func2 之前或之后调用,但函数调用不得以任何方式重叠或交错。

这意味着,如果需要,func1func2 中的每一个都可以与某些共享数据进行交互,而不会以意外的方式更改其下的数据。

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 so func1 may be called before or after func2 but the function calls must not overlap or be interleaved in any way.

This means that each of func1 and func2 can, if desired, interact with some shared data without having that data change under it in an unexpected way.

柒七 2024-08-18 12:48:58

不是期间,但肯定是,要么 1 然后 2,要么 2 然后 1。

Not during, but sure, either 1 then 2 or 2 then 1.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文