This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/20623] ICE: fold check: original tree changed by fold with --enable-checking=fold
- From: "richard dot guenther at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Jun 2007 10:07:26 -0000
- Subject: [Bug middle-end/20623] ICE: fold check: original tree changed by fold with --enable-checking=fold
- References: <bug-20623-7559@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #25 from richard dot guenther at gmail dot com 2007-06-21 10:07 -------
Subject: Re: ICE: fold check: original tree changed by fold with
--enable-checking=fold
On 6/21/07, Sebastian Pop <spop@gcc.gnu.org> wrote
> On 6/21/07, Richard Guenther <richard.guenther@gmail.com> wrote:
> >
> > The fold_binary change looks unnecessary.
>
> ok.
>
> > The rest is ok.
> >
>
> There was something wrong in the rest, so I'm proposing this fix instead,
> as we were not using the modified base anymore for building the result 't'.
>
> @@ -14191,14 +14220,15 @@ build_fold_addr_expr_with_type (tree t,
> }
> else
> {
> - tree base = t;
> + tree copy_t = copy_node (t);
> + tree base = copy_t;
>
> while (handled_component_p (base))
> base = TREE_OPERAND (base, 0);
> if (DECL_P (base))
> TREE_ADDRESSABLE (base) = 1;
>
> - t = build1 (ADDR_EXPR, ptrtype, t);
> + t = build1 (ADDR_EXPR, ptrtype, copy_t);
> }
As you noted copying trees here is wrong, too. We can either try to get rid
of setting the TREE_ADDRESSABLE flag here or fix fold checking code to
ignore this particular change. Note the above code is this way since the
tree-ssa merge.
Another thing would be to note where we call this helper from fold() routines
and not set the flag only for those callers which should be safe. We'd need
another flag argument to the function or another wrapper.
Richard.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20623