aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2026-04-13 15:53:10 +0700
committerGopher Robot <gobot@golang.org>2026-04-13 11:56:30 -0700
commite7c75c3ae80338a635051770052652870679aaf5 (patch)
tree666a920f7ce7c9c3556434ef426bc2a5407c4b01 /src/cmd/compile
parent82c5ec222aa61c24481bee237102b605bd62c292 (diff)
downloadgo-e7c75c3ae80338a635051770052652870679aaf5.tar.xz
cmd/compile: handle min integer step in loop
Since negating min int will overflows back to itself, causing a panic inside subWillUnderflow check. Fixes #78641 Change-Id: Ibbf2fa3228b9890a1a76ac6f4ff504b7e125b29f Reviewed-on: https://go-review.googlesource.com/c/go/+/766260 Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/cmd/compile')
-rw-r--r--src/cmd/compile/internal/ssa/loopbce.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/loopbce.go b/src/cmd/compile/internal/ssa/loopbce.go
index 0d3130fe9a..127018dfb0 100644
--- a/src/cmd/compile/internal/ssa/loopbce.go
+++ b/src/cmd/compile/internal/ssa/loopbce.go
@@ -159,6 +159,12 @@ nextblock:
if step == 0 {
continue
}
+ // step == minInt64 cannot be safely negated below, because -step
+ // overflows back to minInt64. The later underflow checks need a
+ // positive magnitude, so reject this case here.
+ if step == minSignedValue(ind.Type) {
+ continue
+ }
// startBody is the edge that eventually returns to the loop header.
var startBody Edge