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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 45937
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45937&action=edit
gcc9-pr89652.patch

IMHO either we need to do what this patch does, i.e. only remove SAVE_EXPRs
that are in new_ctx.values, or we should save_exprs.empty (); after:
      /* Forget saved values of SAVE_EXPRs.  */
      for (hash_set<tree>::iterator iter = save_exprs.begin();
           iter != save_exprs.end(); ++iter)
        new_ctx.values->remove (*iter);
loop in cxx_eval_loop_expr.  Arguably my patch made things worse, in that there
is this loop and one at the end of function, on the other side before that it
was a latent thing, e.g. if some SAVE_EXPRs are encountered only during certain
iterations of a loop and not others, if we never remove anything from
save_exprs, we'll keep adding all SAVE_EXPRs ever encountered, but then try to
remove even those that were already removed.
Or, yet another option might be change save_exprs into a vec and always
truncate the vec after traversing it for removal from values.

Reply via email to