From a1363f8dd8037d40e9fbf04c2ba8d6d3e7e5c269 Mon Sep 17 00:00:00 2001 From: Filip Kastl Date: Thu, 20 Mar 2025 11:54:59 +0100 Subject: gimple: sccopy: Don't increment i after vec::unordered_remove() I increment the index variable in a loop even when I do vec::unordered_remove() which causes the vector traversal to miss some elements. Mikael notified me of this mistake I made in my last patch. gcc/ChangeLog: * gimple-ssa-sccopy.cc (scc_copy_prop::propagate): Don't increment after vec::unordered_remove(). Reported-by: Mikael Morin Signed-off-by: Filip Kastl --- gcc/gimple-ssa-sccopy.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/gimple-ssa-sccopy.cc b/gcc/gimple-ssa-sccopy.cc index 298feb0..ee2a7fa 100644 --- a/gcc/gimple-ssa-sccopy.cc +++ b/gcc/gimple-ssa-sccopy.cc @@ -582,9 +582,11 @@ scc_copy_prop::propagate () get removed. That means parts of CFG get removed. Those may contain copy statements. For that reason we prune SCCs here. */ unsigned i; - for (i = 0; i < scc.length (); i++) + for (i = 0; i < scc.length ();) if (gimple_bb (scc[i]) == NULL) scc.unordered_remove (i); + else + i++; if (scc.is_empty ()) { scc.release (); -- cgit v1.1