Fix ICE with ODR mering and variable sized types

Jan Hubicka hubicka@ucw.cz
Mon Sep 22 15:37:00 GMT 2014


> On Fri, Sep 19, 2014 at 8:55 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> > Hi,
> > this patch fixes ICE by avoiding mangling of types with variadic size (those are
> > not really supported).  Bootstrapped/regtested x86_64-linux, tested with libreoffice,
> > comitted.
> 
> Hmm, but how do global vars end up having variadic type?  Isn't the
> bug that you are ending up with some local entity here?

We call this on TYPE_NAME of all types, not only global vars.  I do not think I should
skip all types with function context, because static variables may have them (and I do not
track where type comes from because ODR violation is caused even by types not used
in global decls).  For example:

inline
int test()
{
  struct A {int a,b;};
  static struct A testA;
  return testA.a++;
}

creates type A that is local and should be merged interprocedurally I think.

Variadic types indeed can not appear in global declarations, so I think it is safe to ignore them.
I am adding Jason to CC, perhaps he knows better.

Honza
> 
> Richard.
> 
> >         PR lto/63286
> >         * tree.c (need_assembler_name_p): Do not mangle variadic types.
> > Index: tree.c
> > ===================================================================
> > --- tree.c      (revision 215328)
> > +++ tree.c      (working copy)
> > @@ -5003,6 +5003,7 @@ need_assembler_name_p (tree decl)
> >        && decl == TYPE_NAME (TREE_TYPE (decl))
> >        && !is_lang_specific (TREE_TYPE (decl))
> >        && AGGREGATE_TYPE_P (TREE_TYPE (decl))
> > +      && !variably_modified_type_p (TREE_TYPE (decl), NULL_TREE)
> >        && !type_in_anonymous_namespace_p (TREE_TYPE (decl)))
> >      return !DECL_ASSEMBLER_NAME_SET_P (decl);
> >    /* Only FUNCTION_DECLs and VAR_DECLs are considered.  */



More information about the Gcc-patches mailing list