C++ tree inlining bug with dynamic arrays
Jim Wilson
wilson@cygnus.com
Mon Jan 24 22:06:00 GMT 2000
winsup (the cygwin library) fails to compile with the new C++ inlining on
trees code. The problem is that winsup uses dynamic arrays. Here is a
simple testcase
extern void __inline__
sub (int i)
{
volatile char a[i];
return;
}
void
sub2 ()
{
sub (100);
}
In sub, DECL_SIZE (<VAR_DECL a>) is variable size, so it contains a SAVE_EXPR.
The SAVE_EXPR has a context that points at sub. After inlining, the SAVE_EXPR
ends up in sub2, but the context still points at sub, triggering an abort
when we try to emit RTL for it.
cp/optimize.c has code to handle SAVE_EXPR contexts in remap_save_expr.
Unfortunately, this is only called or SAVE_EXPRs that exist in the function
body. It does not get called for SAVE_EXPRs inside a VAR_DECL DECL_SIZE.
I believe that what needs to be done here is to add code to remap_decl
that will walk down the DECL_SIZE tree and copy it. This patch does seem
to work. However, I still get failures, and it turns out that at least one
more thing needs fixing:
TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (decl)))
Also, by looking at the var_decl, I see that
TYPE_SIZE (TREE_TYPE (decl))
is also wrong, but don't know if this will cause a crash.
Index: optimize.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/cp/optimize.c,v
retrieving revision 1.2
diff -p -r1.2 optimize.c
*** optimize.c 2000/01/03 19:18:42 1.2
--- optimize.c 2000/01/25 06:01:42
*************** remap_decl (decl, id)
*** 104,109 ****
--- 104,112 ----
/* Make a copy of the variable or label. */
t = copy_decl_for_inlining (decl, fn,
VARRAY_TREE (id->fns, 0));
+
+ walk_tree (&DECL_SIZE (t), copy_body_r, id);
+
/* Remember it, so that if we encounter this local entity
again we can reuse this copy. */
n = splay_tree_insert (id->decl_map,
More information about the Gcc-bugs
mailing list