Something weird I thought of when reading up on strict aliasing.
Quote on the aliasing rules from the C standard:
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.
Does this mean that if I declare a variable of a type, say,
struct struct1 {
int a;
};
/* ... */
/* an object. The declared type of the object is struct struct1 */
struct struct1 test;
And declare another of a type, say,
struct struct2 { /* an aggregate or union type that includes... */
int a;
struct struct1 test; /* ...one of the aforementioned types among its members:
(the declared type of the object) */
};
/* ... */
struct struct2 test2;
Are they technically supposed to alias, as per the quote above? That seems very wrong.
What am I missing?