This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] PR11679: ICE in finish_file, at cp/decl2.c:2727: varray outof bounds in --enable-checking mode
- From: Raja R Harinath <harinath at cs dot umn dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 26 Jul 2003 23:43:25 -0500
- Subject: [PATCH] PR11679: ICE in finish_file, at cp/decl2.c:2727: varray outof bounds in --enable-checking mode
Hi,
Here's a patch for the testcase in PR11679. The error is:
/home/grad04/harinath/z/z/foo.cc: At global scope:
/home/grad04/harinath/z/z/foo.cc:18526: internal compiler error: virtual array
RTTI decls[10]: element 10 out of bounds in finish_file, at cp/decl2.c:2727
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
A simple patch that fixes it is:
Index: gcc/cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.648
diff -u -p -u -r1.648 decl2.c
--- gcc/cp/decl2.c 19 Jul 2003 16:09:46 -0000 1.648
+++ gcc/cp/decl2.c 27 Jul 2003 04:11:12 -0000
@@ -2723,9 +2723,10 @@ finish_file ()
them to the beginning of the array, then get rid of the
leftovers. */
n_new = VARRAY_ACTIVE_SIZE (unemitted_tinfo_decls) - n_old;
- memmove (&VARRAY_TREE (unemitted_tinfo_decls, 0),
- &VARRAY_TREE (unemitted_tinfo_decls, n_old),
- n_new * sizeof (tree));
+ if (n_new)
+ memmove (&VARRAY_TREE (unemitted_tinfo_decls, 0),
+ &VARRAY_TREE (unemitted_tinfo_decls, n_old),
+ n_new * sizeof (tree));
memset (&VARRAY_TREE (unemitted_tinfo_decls, n_new),
0,
n_old * sizeof (tree));
If VARRAY_TREE is supposed to support one-past-the-end, then
VARRAY_CHECK has to be fixed instead. That option is much more
far-reaching, and will need to change the implementation of
VARRAY_CHECK since it already has a pointer dereference inside it.
Given the current implementation of varray.h, it leads me to think
that the usage of one-past-the-end pointers are not allowed, and so a
technique like in the patch has to be implemented.
- Hari
Index: gcc/cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.648
diff -u -p -u -r1.648 decl2.c
--- gcc/cp/decl2.c 19 Jul 2003 16:09:46 -0000 1.648
+++ gcc/cp/decl2.c 27 Jul 2003 04:11:12 -0000
@@ -2723,9 +2723,10 @@ finish_file ()
them to the beginning of the array, then get rid of the
leftovers. */
n_new = VARRAY_ACTIVE_SIZE (unemitted_tinfo_decls) - n_old;
- memmove (&VARRAY_TREE (unemitted_tinfo_decls, 0),
- &VARRAY_TREE (unemitted_tinfo_decls, n_old),
- n_new * sizeof (tree));
+ if (n_new)
+ memmove (&VARRAY_TREE (unemitted_tinfo_decls, 0),
+ &VARRAY_TREE (unemitted_tinfo_decls, n_old),
+ n_new * sizeof (tree));
memset (&VARRAY_TREE (unemitted_tinfo_decls, n_new),
0,
n_old * sizeof (tree));
--
Raja R Harinath ------------------------------ harinath@cs.umn.edu