I have something like this:
union DataXYZ
{
struct complex_t
{
float real, imag;
} complex;
struct vector_t
{
float magnitude, phase;
} vector;
};
I have some vectors of these, being general-purpose workspace memory, where I use the fields accordingly after the semantic context.
I know it's undefined behaviour to read a field in a union, when the last active member was another field (and type?). Does this matter when the types and layout match exactly?
I've been commenting on some other similar questions, asking for references that guarantee the behaviour, but nothing came up yet - hence this question.