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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2026-01-30
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I'll note that gimplify_cond_expr uses
!TREE_SIDE_EFFECTS && !generic_expr_could_trap_p but that's not what code
in fold-const.cc does, but it does not have this kind of simplification
(on the 7 branch at least).

The following forces us to do the same on conditional executed match captures:

diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
index 633ff9e1db2..2f8d85917db 100644
--- a/gcc/genmatch.cc
+++ b/gcc/genmatch.cc
@@ -4384,8 +4384,9 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple,
operand *result)
                         & cinfo.force_no_side_effects) == 0)
              {
                fprintf_indent (f, indent,
-                               "if (TREE_SIDE_EFFECTS (captures[%d])) "
-                               "goto %s;\n", i, fail_label);
+                               "if (TREE_SIDE_EFFECTS (captures[%d]) "
+                               "|| generic_expr_could_trap_p (captures[%d])) "
+                               "goto %s;\n", i, i, fail_label);
                needs_label = true;
                if (verbose >= 1)
                  warning_at (cinfo.info[i].c->location,

Reply via email to