Patch for template bug

Mark Mitchell mmitchell@usa.net
Fri Dec 12 14:32:00 GMT 1997


Some storage was beeing freed, and then looked at later in your
template test program.  Here's a fix.

-- 
Mark Mitchell		mmitchell@usa.net
Stanford University	http://www.stanford.edu

1997-12-12  Mark Mitchell  <mmitchell@usa.net>

	* decl.c (duplicate_decls): Do not throw away new declarations
	that may be kept on template instantiation/specialization lists.

Index: decl.c
===================================================================
RCS file: /home/mitchell/Repository/egcs/gcc/cp/decl.c,v
retrieving revision 1.6
diff -c -p -r1.6 decl.c
*** decl.c	1997/12/08 07:44:18	1.6
--- decl.c	1997/12/12 21:37:06
*************** duplicate_decls (newdecl, olddecl)
*** 2963,2969 ****
  #define ROUND(x) ((x + obstack_alignment_mask (&permanent_obstack)) \
  		  & ~ obstack_alignment_mask (&permanent_obstack))
  
!       if ((char *)newdecl + ROUND (function_size)
  	  + ROUND (sizeof (struct lang_decl))
  	  == obstack_next_free (&permanent_obstack))
  	{
--- 2963,2974 ----
  #define ROUND(x) ((x + obstack_alignment_mask (&permanent_obstack)) \
  		  & ~ obstack_alignment_mask (&permanent_obstack))
  
!       if (DECL_TEMPLATE_INSTANTIATION (newdecl) 
! 	  || DECL_TEMPLATE_SPECIALIZATION (newdecl))
! 	/* The newdecl will be stored on the list of instantiations or
! 	   specializations for this template, so we must keep it.  */
! 	;
!       else if ((char *)newdecl + ROUND (function_size)
  	  + ROUND (sizeof (struct lang_decl))
  	  == obstack_next_free (&permanent_obstack))
  	{



More information about the Gcc mailing list