[Bug c++/54652] New: ICE with -g

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Sep 21 09:49:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54652

             Bug #: 54652
           Summary: ICE with -g
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jakub@gcc.gnu.org
                CC: jason@gcc.gnu.org


typedef unsigned long L __attribute__ ((aligned));
typedef unsigned long L __attribute__ ((aligned));

template <typename T>
struct S
{
  union U { L l; } u;
};

S <int> s;

ICEs with -g, TYPE_NAME seems to be garbage.
The problem is that handle_aligned_attribute first (with L as decl):
          tree tt = TREE_TYPE (decl);
          *type = build_variant_type_copy (*type);
          DECL_ORIGINAL_TYPE (decl) = tt;
          TYPE_NAME (*type) = decl;
          TREE_USED (*type) = TREE_USED (decl);
          TREE_TYPE (decl) = *type;
then duplicate_decls is called on the L olddecl (with new L as newdecl), where
TYPE_NAME (TREE_TYPE (olddecl)) == olddecl and
TYPE_NAME (TREE_TYPE (newdecl)) == newdecl, in merge_types newdecl's type wins,
and eventually ggc_free (newdecl);
So, either something should have changed TYPE_NAME (newtype) from newdecl to
olddecl before ggc_free (I guess that would be preferred, but can't it be
TYPE_NAME of other related types too?), or we shouldn't ggc_free TYPE_DECLs.
Jason, can you please look into this?



More information about the Gcc-bugs mailing list