c++ - 赋值操作标准变更

标签 c++ c++11

有人可以举例说明新标准中以下内容的变化吗?这是指严格的别名规则吗?

5.17/8. If the value being stored in an object is accessed from another object that overlaps in any way the storage of the first object, then the overlap shall be exact and the two objects shall have the same type, otherwise the behavior is undefined.

在新标准中,它被更改为以下注释:

[ Note: This restriction applies to the relationship between the left and right sides of the assignment operation; it is not a statement about how the target of the assignment may be aliased in general. See 3.10. — end note ]

最佳答案

这解释了变化:http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#556

There appear to be two different specifications for when aliasing is permitted.

[...]

This issue is based on a misunderstanding of the intent of the wording in 5.17 [expr.ass] paragraph 8. Instead of being a general statement about aliasing, it's describing the situation in which the source of the value being assigned is storage that overlaps the storage of the target object. The proposed resolution should make that clearer rather than changing the specification.

关于c++ - 赋值操作标准变更,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8423713/

相关文章:

c++ - 使用结构作为库的全局

c++ - 在 C++ 中发送崩溃报告、产品注册等的正常方法是什么?

c++ - OpenSSL DER ECDSA 编码错误

c++ - 理论上,find_end 是可并行化的吗?

c++ - 是否可以将 Qt Creator 2.7 与 Visual Studio 2012 编译器一起使用并拥有其所有功能?

c++ - g++ 不允许使用标识符中的😃(和其他 Unicode 字符)

c++ - 选项卡之间的 IE BHO c++ 数据共享

c++ - 为什么 char* 总是和字符串的 len 一起传递给 FUNCTION

c++ - 为什么我不能在 c++0x 的 lambda 中声明一个结构变量?

c++ - 对 boost asio 完成处理程序的右值引用