[Bug c++/28525] New: ICE after duplicate_decls

reichelt at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Jul 28 11:27:00 GMT 2006


While debugging PR 28274 I came across the following problem:

If I apply the second hunk of the patch below, the C++ frontend
crashes on the following code:

======================
void foo();
void foo() {}
======================

  <built-in>:0: note: OLD DECL2 'struct std::type_info'
  zsh: 25734 segmentation fault  cc1plus -quiet ~/file.cc

If I also apply the first hunk, erverything works as expected:

  <built-in>:0: note: OLD DECL1 'struct std::type_info'
  <built-in>:0: note: OLD DECL2 'struct std::type_info'
  file.cc: In function 'void foo()':
  file.cc:2: note: OLD DECL1 'void foo()'
  file.cc:2: note: OLD DECL2 'void foo()'
  file.cc: At global scope:
  file.cc:1: note: OLD DECL1 'struct __cxxabiv1::__fundamental_type_info'
  file.cc:1: note: OLD DECL2 'struct __cxxabiv1::__fundamental_type_info'

There seems to be a problem with garbage collection somewhere.

Instead of adding the first hunk, commenting out the call
ggc_free (newdecl);
at the end of duplicate_decls (decl.c) makes things work, too.

Happens on mainline, 4.1 branch, and 4.0 branch
(x86_64-unknown-linux-gnu with checking enabled).

Might be related to PR 27100.

===================================================================
--- gcc/gcc/cp/name-lookup.c    (revision 115789)
+++ gcc/gcc/cp/name-lookup.c    (working copy)
@@ -720,7 +720,9 @@ pushdecl_maybe_friend (tree x, bool is_friend)
            }
          else
            {
-             tree olddecl = duplicate_decls (x, t, is_friend);
+             tree olddecl;
+             inform ("OLD DECL1 %qD", t);
+             olddecl = duplicate_decls (x, t, is_friend);

              /* If the redeclaration failed, we can stop at this
                 point.  */
@@ -729,6 +731,8 @@ pushdecl_maybe_friend (tree x, bool is_friend)

              if (olddecl)
                {
+                 inform ("OLD DECL2 %qD", t);
+
                  if (TREE_CODE (t) == TYPE_DECL)
                    SET_IDENTIFIER_TYPE_VALUE (name, TREE_TYPE (t));

===================================================================


-- 
           Summary: ICE after duplicate_decls
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code, GC
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list