Could a C++ implementation, in theory, parallelise the evaluation of two function arguments?

后端 未结 4 1857
隐瞒了意图╮
隐瞒了意图╮ 2020-12-23 14:14

Given the following function call:

f(g(), h())

since the order of evaluation of function arguments is unspecified (still the case in C++11

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-23 15:11

    As long as you can't tell, whatever the compiler does to evaluate these functions is entirely up to the compiler. Clearly, the evaluation of the functions cannot involve any access to shared, mutable data as this would introduce data races. The basic guiding principle is the "as if"-rule and the fundamental observable operations, i.e., access to volatile data, I/O operations, access to atomic data, etc. The relevant section is 1.9 [intro.execution].

提交回复
热议问题