On Sat, Jun 28, 2014 at 8:22 PM, Jan Hubicka <hubi...@ucw.cz> wrote: > Hi, > This is first bug noticed by the type consistency checks I added. > > gcov_info_type is a structure that contains function pointer to itself. While > building it we first build a structure w/o size and fields, then we build a > function type that produces a qualified variant of the structure (not sure why > that legwork is needed). Then we add fields via finish_builtin_struct. > It sets the fields to structure but not its variant and then does layout_type > that actually copies size to all variants. So we end up with TYPE_COMPLETE_P > variant > that has size but no fields. This is quite obviously wrong. > > Fixed thus. Bootstrapped, lto-bootstrapped and regtested x86_64-linux, > comitted. > > * stor-layout.c (finish_builtin_struct): Copy fields into > the variants. > > Index: stor-layout.c > =================================================================== > --- stor-layout.c (revision 212098) > +++ stor-layout.c (working copy) > @@ -2065,7 +2065,7 @@ void > finish_builtin_struct (tree type, const char *name, tree fields, > tree align_type) > { > - tree tail, next; > + tree tail, next, variant; > > for (tail = NULL_TREE; fields; tail = fields, fields = next) > { > @@ -2074,6 +2074,10 @@ finish_builtin_struct (tree type, const > DECL_CHAIN (fields) = tail; > } > TYPE_FIELDS (type) = tail; > + for (variant = TYPE_MAIN_VARIANT (type); > + variant != 0; > + variant = TYPE_NEXT_VARIANT (variant)) > + TYPE_FIELDS (variant) = tail;
I think that's a bogus place to fix that. Instead the caller should use build_variant_type_copy. Especially that the fixup above depends on all variants being added before finish_builtin_struct is called. Please revert the above. Thanks, Richard. > if (align_type) > {