What rules are there for qualifiers of effective type?

不想你离开。 提交于 2021-01-28 11:32:51

问题


So I was re-reading C17 6.5/6 - 6.5/7 regarding effective type and strict aliasing, but couldn't figure out how to treat qualifiers. Some things confuse me:

  • I always assumed that qualifiers aren't really relevant for effective type since the rules speak of lvalue access, meaning lvalue conversion that discards qualifiers. But what if the object is a pointer? Qualifiers to the pointed-at data aren't affected by lvalue conversion.

    Q1: What if the effective type is a pointer to qualified-type? Can I lvalue access it as a non-qualified pointer to the same type? Where in the standard is this stated?

  • The exceptions to the strict aliasing rule mention qualifiers in these cases:

    — a qualified version of a type compatible with the effective type of the object,
    — a type that is the signed or unsigned type corresponding to the effective type of the object,
    — a type that is the signed or unsigned type corresponding to a qualified version of the effective type of the object,

    None of these address qualifiers of the effective type itself, only by the lvalue used for access. Which should be quite irrelevant, because of lvalue conversion... right?

    Q2: Does lvalue conversion happen before or after the above quoted rules of effective type/strict aliasing are applied?

    Q3: Does the effective type come with qualifiers or not? Where in the standard is this stated?

来源:https://stackoverflow.com/questions/65356861/what-rules-are-there-for-qualifiers-of-effective-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!