[C++ Patch] Variable expression for array initializer segfaults

Craig Rodrigues rodrigc@attbi.com
Sat Apr 20 09:20:00 GMT 2002


Hi,

The following testcase supplied with PR 5919 causes the
compiler to segfault:

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5919

#include <vector>
#include<algorithm>
 
int main() {
        std::vector<int> v1, v2;
        int score[v1.size()+1][v2.size()+1];
        std::fill(score, score+(v1.size()+1)*(v2.size()+1), 0);
        return 0;
}


The following patch eliminates the segfault:


Index: mangle.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/mangle.c,v
retrieving revision 1.44.2.3
diff -u -r1.44.2.3 mangle.c
--- mangle.c	18 Mar 2002 15:37:35 -0000	1.44.2.3
+++ mangle.c	20 Apr 2002 16:16:32 -0000
@@ -1836,7 +1836,8 @@
 	}
       
       /* If it wasn't any of those, recursively expand the expression.  */
-      write_string (operator_name_info[(int) code].mangled_name);
+      if ( operator_name_info[(int) code].mangled_name )
+        write_string (operator_name_info[(int) code].mangled_name);
 
       switch (code)
 	{



Is this patch OK?

-- 
Craig Rodrigues        
http://www.gis.net/~craigr    
rodrigc@attbi.com



More information about the Gcc-patches mailing list