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]

Re: g++ 2.96 new ICE with templates.



This patch fixes the problem Alfred reported.  It also fixes a related
problem on an obscure test-case that predates my recent changes; at
least as far back as the EGCS 1.0 series.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

1999-08-26  Mark Mitchell  <mark@codesourcery.com>

	* tree.c (store_parm_decls): Reset immediate_size_expand.
	(finish_function): Likewise.

Index: testsuite/g++.old-deja/g++.ext/array3.C
===================================================================
RCS file: array3.C
diff -N array3.C
*** /dev/null	Sat Dec  5 20:30:03 1998
--- array3.C	Thu Aug 26 20:06:05 1999
***************
*** 0 ****
--- 1,10 ----
+ // Build don't link:
+ // Origin: Mark Mitchell <mark@codesourcery.com>
+ // Special g++ Options: 
+ 
+ void *vp;
+ 
+ void f ()
+ {
+   int i = (*((int (*)[i]) vp))[0];
+ }
Index: testsuite/g++.old-deja/g++.pt/array6.C
===================================================================
RCS file: array6.C
diff -N array6.C
*** /dev/null	Sat Dec  5 20:30:03 1998
--- array6.C	Thu Aug 26 20:06:07 1999
***************
*** 0 ****
--- 1,16 ----
+ // Build don't link:
+ // Origin: Alfred Minarik <a8601248@unet.univie.ac.at>
+ // Special g++ Options: 
+ 
+ template<typename _CharT>
+ struct basic_filebuf
+ {
+   virtual void 
+   underflow()
+     {
+       int __size = 5;
+       char __conv_buf[__size];
+     }
+ };
+ 
+ template class basic_filebuf<char>;
Index: cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.415
diff -c -p -r1.415 decl.c
*** decl.c	1999/08/26 04:19:51	1.415
--- decl.c	1999/08/27 03:06:32
*************** store_parm_decls ()
*** 13232,13237 ****
--- 13232,13243 ----
  
    /* Initialize RTL machinery.  */
    init_function_start (fndecl, input_filename, lineno);
+   /* Even though we're inside a function body, we still don't want to
+      call expand_expr to calculate the size of a variable-sized array.
+      We haven't necessarily assigned RTL to all variables yet, so it's
+      not safe to try to expand expressions involving them.  */
+   immediate_size_expand = 0;
+   get_pending_sizes ();
  
    /* Create a binding level for the parms.  */
    expand_start_bindings (0);
*************** finish_function (lineno, flags, nested)
*** 13818,13823 ****
--- 13824,13835 ----
  	     for error checking purposes.  */
  	  expand_label (no_return_label);
  	}
+ 
+       /* We hard-wired immediate_size_expand to zero in
+ 	 start_function.  Expand_function_end will decrement this
+ 	 variable.  So, we set the variable to one here, so that after
+ 	 the decrement it will remain zero.  */
+       immediate_size_expand = 0;
  
        /* Generate rtl for function exit.  */
        expand_function_end (input_filename, lineno, 1);


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