https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95976
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2020-06-30 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Keywords| |ABI CC| |jason at gcc dot gnu.org, | |redi at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- One way to fix this would be: --- gcc/cp/class.c.jj 2020-06-27 12:35:11.935311848 +0200 +++ gcc/cp/class.c 2020-06-30 14:18:08.448067688 +0200 @@ -6575,7 +6575,9 @@ layout_class_type (tree t, tree *virtual /* We must also reset the DECL_MODE of the field. */ SET_DECL_MODE (field, TYPE_MODE (type)); } - else if (might_overlap && is_empty_class (type)) + else if (might_overlap + && is_empty_class (type) + && TREE_CODE (t) != UNION_TYPE) { DECL_FIELD_ABI_IGNORED (field) = 1; layout_empty_base_or_field (rli, field, empty_base_offsets); Another might be not to change DECL_FIELD_OFFSET in layout_empty_base_or_field for TREE_CODE (rli->t) == UNION_TYPE, etc. The question is if [[no_unique_address]] members of a union should affect any ABI decisions (such as passing the union by value) or not. Looking at the config/*/* code, in most cases the targets ignore DECL_FIELD_ABI_IGNORED on UNION_TYPE members, but ia64 does not, and I think rs6000_special_round_type_align and darwin_rs6000_special_round_type_align don't ignore it either.