This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

More Dwarf2 issues



The following small C++ program:

  inline void f() {
    struct S {};
    S s;
  }

  int g()
  {
    for (int i = 0; i < 2; ++i)
      f();
  }

causes a crash when compiled -O2 -gdwarf-2:

~/projects/egcs-1.1/objdir/gcc/cc1plus -O2 -gdwarf-2 bug3.C
 void f() int g()../../gcc/dwarf2out.c:9085: Internal compiler error in function gen_tagged_type_instantiation_die

The assertion that is trapping is:

  if (type != type_main_variant (type))
    abort();

Here, we've made a copy of `S' in pushdecl, when called from
integrate_decl_trees, and that causes the confusion.  I've attached a
patch for this bug, but I did not check this in, because I'm not sure
it's the right thing to do.  What do you two think?

A much bigger C++ program, to which I cannot provide the source,
unfortunately, exhibits a perhaps related, but different problem,
again related to the build_type_copy stuff.  In particular, there is
something like:

  template <class T>
  inline void f(T) {
    typedef typename T::I I;
    I();
  }

  struct S {
    struct I { 
      I();
    };
  };

  int g()
  {
    for (int i = 0; i < 2; ++i)
      f(S());
  }

although this test-case does not exhibit the bug.  The bug only
appears with -gdwarf-2 -O2 -funroll-loops.  There, the trap happens in
scope_die_for, called from decls_for_scope.  The parameter `t' to
scope_die_for is the TYPE_DECL for f(S)::I, whose DECL_CONTEXT is a
FUNCTION_DECL.  This FUNCTION_DECL becomes the `containing_scope'
variable, but the containing_scope is not in the decl_scope_table, and
scope_die_for aborts.  What do you two think about all this?

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com

1998-07-31  Mark Mitchell  <mark@markmitchell.com>

	* decl.c (pushdecl): Don't copy types if the
	DECL_ABSTRACT_ORIGIN of the new decl matches the TYPE_NAME of the
	type. 

===================================================================
RCS file: crash3.C
diff -N crash3.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- crash3.C	Fri Jul 31 15:18:33 1998
***************
*** 0 ****
--- 1,14 ----
+ // Build don't link:
+ // Special g++ Options: -g
+ 
+ inline void f() {
+   struct S {};
+   S s;
+ }
+ 
+ int g()
+ {
+   for (int i = 0; i < 2; ++i)
+     f();
+ }
+ 
Index: cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.172
diff -c -p -r1.172 decl.c
*** decl.c	1998/07/29 14:56:33	1.172
--- decl.c	1998/07/31 21:43:58
*************** pushdecl (x)
*** 3442,3448 ****
  	      if (TYPE_NAME (type) == 0)
  	        TYPE_NAME (type) = x;
              }
!           else if (type != error_mark_node && TYPE_NAME (type) != x)
              {
  	      push_obstacks (TYPE_OBSTACK (type), TYPE_OBSTACK (type));
  
--- 3470,3480 ----
  	      if (TYPE_NAME (type) == 0)
  	        TYPE_NAME (type) = x;
              }
!           else if (type != error_mark_node && TYPE_NAME (type) != x
! 		   /* We don't want to copy the type when all we're
! 		      doing is making a TYPE_DECL for the purposes of
! 		      inlining.  */
! 		   && TYPE_NAME (type) != DECL_ABSTRACT_ORIGIN (x))
              {
  	      push_obstacks (TYPE_OBSTACK (type), TYPE_OBSTACK (type));
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]