#include <iostream>

union A {
    int i;
    double d;
    char c;
}; // the whole union occupies max(sizeof(int), sizeof(double), sizeof(char))

int main()
{
    A a = { 43 }; // initializes the first member, a.i is now the active member
    // at this point, reading from a.d or a.c is UB
    std::cout << "a.i = " << a.i << std::endl;
    a.c = 'a'; // a.c is now the active member
    // at this point, reading from i or d is UB but most compilers define this
    std::cout << "a.i = " << a.i << std::endl; // 97 most likely
    return 0;
}