This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug c++/70590] [6 Regression] r234810 causes error: location references block not in block tree


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70590

--- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Markus Trippelsdorf from comment #6)
> (In reply to Patrick Palka from comment #5)
> > (In reply to Markus Trippelsdorf from comment #4)
> > > (In reply to Patrick Palka from comment #3)
> > > > (In reply to Jakub Jelinek from comment #2)
> > > > > location references block not in block tree generally means insufficient
> > > > > unsharing, where some function that got through gimple-low.c where
> > > > > TREE_SET_BLOCK has been used on some of the trees is sharing trees with a
> > > > > different function.
> > > > 
> > > > That makes sense.  So in cxx_eval_call_expression we should unconditionally
> > > > unshare the result of the call because the two caches (fundef_copies_table
> > > > and constexpr_call_table) may cause us to share the same trees in different
> > > > functions.  Alternatively we can just call unshare_expr once in the
> > > > top-level cxx_eval_outermost_constant_expression, I think.  Markus, does
> > > > this patch fix the build for you?
> > > 
> > > No. It now ICEs: in maybe_constant_value_1, at cp/constexpr.c:4328
> > 
> > What about just this instead?
> 
> This one fixes the issue. Firefox now builds fine. Thanks.

Markus, when you have time, can you please test this patch?

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 649d336..6acd5fc 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -4144,6 +4144,9 @@ cxx_eval_outermost_constant_expr (tree t, bool
allow_non_constant,

   r = cxx_eval_constant_expression (&ctx, r,
                                    false, &non_constant_p, &overflow_p);
+  if (r != t
+      && TREE_CODE (r) != CONSTRUCTOR)
+    r = unshare_expr (r);

   verify_constant (r, allow_non_constant, &non_constant_p, &overflow_p);


It is one that I'm more comfortable with.(In reply to Markus Trippelsdorf from
comment #6)
> (In reply to Patrick Palka from comment #5)
> > (In reply to Markus Trippelsdorf from comment #4)
> > > (In reply to Patrick Palka from comment #3)
> > > > (In reply to Jakub Jelinek from comment #2)
> > > > > location references block not in block tree generally means insufficient
> > > > > unsharing, where some function that got through gimple-low.c where
> > > > > TREE_SET_BLOCK has been used on some of the trees is sharing trees with a
> > > > > different function.
> > > > 
> > > > That makes sense.  So in cxx_eval_call_expression we should unconditionally
> > > > unshare the result of the call because the two caches (fundef_copies_table
> > > > and constexpr_call_table) may cause us to share the same trees in different
> > > > functions.  Alternatively we can just call unshare_expr once in the
> > > > top-level cxx_eval_outermost_constant_expression, I think.  Markus, does
> > > > this patch fix the build for you?
> > > 
> > > No. It now ICEs: in maybe_constant_value_1, at cp/constexpr.c:4328
> > 
> > What about just this instead?
> 
> This one fixes the issue. Firefox now builds fine. Thanks.

When you have time, could you please test this patch?

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 7f4bb04..b66cbad 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -4143,6 +4143,12 @@ cxx_eval_outermost_constant_expr (tree t, bool
allow_non_constant,

   verify_constant (r, allow_non_constant, &non_constant_p, &overflow_p);

+  /* Unshare the result unless it's a CONSTRUCTOR in which case it's already
+     unshared.  */
+  if (r != t
+      && TREE_CODE (r) != CONSTRUCTOR)
+    r = unshare_expr (r);
+
   /* Mutable logic is a bit tricky: we want to allow initialization of
      constexpr variables with mutable members, but we can't copy those
      members to another constexpr variable.  */

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