gpt4 book ai didi

c++ - C89 或 C++03 是否定义了严格的别名规则?

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

我看过 several assertions C89 和 C++03 定义了严格的别名规则。但是,我无法在标准中找到该特定位。我的理解是 C99 中添加了严格的别名规则。

最佳答案

此文本出现在 C89,§3.3 表达式中:

An object shall have its stored value accessed only by an lvalue that has one of the following types:

  • the declared type of the object,

  • a qualified version of the declared type of the object,

  • a type that is the signed or unsigned type corresponding to the
    declared type of the object,

  • a type that is the signed or unsigned type corresponding to a
    qualified version of the declared type of the object,

  • an aggregate or union type that includes one of the aforementioned
    types among its members (including, recursively, a member of a
    subaggregate or contained union), or

  • a character type.

违反“应”约束会导致未定义的行为,因此可以从此文本中导出一组允许的别名规则。

关于c++ - C89 或 C++03 是否定义了严格的别名规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6514663/

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