The C standard states (emphasize mine):
28 A pointer to void
shall have the same representation and alignment requirements as a pointer to a character type.48) Similarly, pointers to qualified or unqualified versions of compatible types shall have the same representation and alignment requirements. All pointers to structure types shall have the same representation and alignment requirements as each other. All pointers to union types shall have the same representation and alignment requirements as each other. Pointers to other types need not have the same representation or alignment requirements.
48) The same representation and alignment requirements are meant to imply interchangeability as arguments to functions, return values from functions, and members of unions.
Source: C11, §6.2.5/28
The wording of "the same representation and alignment" happens here often.
But what about the same size?
I wonder if there can be a difference between between these pointer objects in terms of the allocated size since the size of a pointer object can vary between the type pointed to even if the alignment and representation is the same.
Or in other words: Is there a guarantee that if the alignment and/or representation is equal, the size is so too?
Question:
- Is the size of an object equivalent to the size of another based upon the same alignment and/or representation?
Annotations:
The question is not specific to pointer objects only. The pointer guidance was just a reference to my mindset as it is a good example.
Citations from the standard are highly appreciated. Accepted answer must have quotations from the standard.
Setting is the exact same specific implementation. I don't talk about various alignments/representations/sizes of objects between different implementations.
Related (regarding the pointer example):
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…