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]

PATCH for template bug, perhaps for 1.1?



Here's a patch that prevents us from reading reused memory.  Without
this patch, the following test case yields:

  bug1.C:16: sorry, not implemented: use of `(null)' in template

Perhaps this patch should be applied to 1.1 branch as well as the
mainline?

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

Index: testsuite/g++.old-deja/g++.pt/crash16.C
===================================================================
RCS file: crash16.C
diff -N crash16.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- crash16.C	Sun Aug  2 21:09:51 1998
***************
*** 0 ****
--- 1,28 ----
+ // Build don't link:
+ // Special g++ Options:
+ 
+ extern "C" void qsort();
+ 
+ struct R {
+   int count;
+   int state1;
+   int state2;
+ };
+ 
+ int cmp_d(const R* a, const R* b) {
+   return a->count > b->count;
+ }
+ 
+ namespace CXX {
+   template<class T, int i1, int i2>
+     inline void qsort (T b[i1][i2], int (*cmp)(const T*, const T*)) {
+     ::qsort ((void*)b, i1*i2, sizeof(T), (int (*)(const void *, const void *))cmp);
+   }
+ }
+ 
+ using namespace CXX;
+ 
+ void sort_machine() {
+   struct R d[256][256];
+   qsort<R,256> (d, cmp_d);
+ }
Index: cp/tree.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/tree.c,v
retrieving revision 1.54
diff -c -p -r1.54 tree.c
*** tree.c	1998/07/27 14:38:08	1.54
--- tree.c	1998/08/03 04:13:28
*************** build_min VPROTO((enum tree_code code, t
*** 2022,2028 ****
  
    t = make_node (code);
    length = tree_code_length[(int) code];
!   TREE_TYPE (t) = tt;
    TREE_COMPLEXITY (t) = lineno;
  
    for (i = 0; i < length; i++)
--- 2027,2033 ----
  
    t = make_node (code);
    length = tree_code_length[(int) code];
!   TREE_TYPE (t) = copy_to_permanent (tt);
    TREE_COMPLEXITY (t) = lineno;
  
    for (i = 0; i < length; i++)


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