On Fri, Jul 30, 2021 at 01:10:33AM -0400, Jason Merrill wrote: > On 7/29/21 10:21 AM, Jakub Jelinek wrote: > > On Thu, Jul 29, 2021 at 09:50:10AM +0200, Jakub Jelinek via Gcc-patches > > wrote: > > > Now that I'm writing the above text and rereading the > > > pointer-interconvertibility definition, I think my > > > first_nonstatic_data_member_p > > > and fold_builtin_is_pointer_inverconvertible_with_class have one bug, > > > for unions the pointer inter-convertibility doesn't talk about std layout > > > at > > > all, so I think I need to check for std_layout_type_p only for non-union > > > class types and accept any union, std_layout_type_p or not. But when > > > recursing from a union type into anonymous structure type punt if the > > > anonymous structure type is not std_layout_type_p + add testcase coverage. > > > > For this part, here is an incremental fix. Tested on x86_64-linux. > > > > It also shows that in the case (we're beyond the standard in this case > > because anonymous structures are not in the standard) of union with > > non-std-layout anonymous structure in it, in the case in the testcases like: > > struct D {}; > > struct E { [[no_unique_address]] D e; }; > > union Y { int a; struct : public E { short b; long c; }; long long d; }; > > We don't already reject an anonymous struct with bases? I think we should > do so, in fixup_anonymous_aggr. We might even require anonymous structs to > be standard-layout.
Apparently not, the above is accepted. I was looking for an example of non-stdlayout anon aggregate in union and my first try (mixing private/public members) has been rejected. > I'm inclined not to handle this extension case specifically. You mean not to even recurse into anonymous structures in the function, or something else? Jakub