问题
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