开发者

subexpressions evaluation order

开发者 https://www.devze.com 2022-12-11 20:21 出处:网络
I\'ve looked at SO/IEC 9899:201x开发者_JAVA百科 under J.1 Unspecified behavior: \"The order in which subexpressions are evaluated and the order in which side effects

I've looked at SO/IEC 9899:201x开发者_JAVA百科 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() ?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消