我有一个标准布局联合,其中包含一大堆类型:
union Big {
    Hdr h;
    A a;
    B b;
    C c;
    D d;
    E e;
    F f;
};
每种类型的A直通F是标准布局和具有作为其第一元件类型的对象Hdr.该Hdr标识了工会的积极成员为,所以这是变体样.现在,我处于一种我确定知道的情况(因为我检查过),活跃成员是a B或a C.实际上,我已将空间减少到:
union Little {
    Hdr h;
    B b;
    C c;
};
现在,是以下明确定义还是未定义的行为?
void given_big(Big const& big) {
    switch(big.h.type) {
    case B::type: // fallthrough
    case C::type:
        given_b_or_c(reinterpret_cast<Little const&>(big));
        break;
    // ... other cases here ...
    }
}
void given_b_or_c(Little const& little) {
    if (little.h.type == B::type) {
        use_a_b(little.b);
    } else …