gpt4 book ai didi

c++ - 为什么 C++ 标准 1.9/5 谈论 "possible execution sequences"?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:50:09 27 4
gpt4 key购买 nike

根据 C++03 标准 1.9/5

A conforming implementation executing a well-formed program shall produce the same observable behavior as one of the possible execution sequences of the corresponding instance of the abstract machine with the same program and the same input.

我不明白“作为其中一个”部分。

如果我有一个特定的程序和一个特定的输入,并且我的程序不包含未定义的行为,为什么可观察到的行为会有所不同? “一种可能的执行顺序”是什么意思?

最佳答案

在 C++ 中,某些事情留给了实现。例如,当你写

int x = f(a) + f(b);

实现可以选择先调用 f(a) 还是先调用 f(b)。

关于c++ - 为什么 C++ 标准 1.9/5 谈论 "possible execution sequences"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11562375/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com