At most one variant member of a union may have a default member initializer. The case of anonymous records with multiple levels of nesting like the following also needs to meet this rule. The original logic is to horizontally obtain all the member variables in a record that need to be initialized and then filter to the variables that need to be fixed. Obviously, it is impossible to correctly initialize the desired variables according to the nesting relationship.
See Example 3 in class.union
union U { U() {} int x; // int x{}; union { int k; // int k{}; <== wrong fix }; union { int z; // int z{}; <== wrong fix int y; }; };
Can it be modified to the following form? Or further abstract filter into a parameter to make this function more general.