是否存在代码在 c++11 中具有序列点但在 c++03 中没有的情况?
现在新的 c++11 标准已经对序列点的描述方式进行了更改,我正在尝试找出 c++03 和 c++11 之间到底发生了什么变化。
特别是,是否存在看起来相同的代码在 c++11 中具有序列点但在 c++03 中没有的情况?
Now that the new c++11 standard has made changes in how sequence points are described I'm trying to find out exactly what has been changed between c++03 and c++11.
In particular, are there any situations where code that looks the same would have a sequence point in c++11 but not c++03?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
C++11 中没有顺序点,而是存在顺序前和顺序后的关系。
以下是一些简单的示例,其中 C++03 和 C++11 之间的行为有所不同,
为什么?查看此答案和相关线程。
There are no sequence points in C++11, rather there are sequenced before and sequenced after relations.
Here are some trivial examples wherein behavior differ between C++03 and C++11
Why? Have a look at this answer and related threads.
我认为最著名的例子是预增量运算符。
在 C++03 中,这将是 UB,而在 C++11 中,每个赋值都在下一次求值之前排序。
在标准中寻找差异是很困难的,因为他们摆脱了“序列点”术语,转而使用“顺序点”等类似术语,并从头开始重写了许多规则。
I think the best known example is the pre-increment operator.
In C++03, this would be UB, and in C++11, each assignment is ordered before the next evaluation.
Searching the Standard for differences is tough because they got rid of the "sequence point" terminology in favor of "ordered before" and the like, and rewrote much of the rules from scratch.