func main() {
for i := math.MinInt64 + 2; i >= math.MinInt64; i-- {
if i == math.MaxInt64 {
break
}
println(i)
}
}
This program will loop forever when it shouldn't. You can "fix" it by passing -gcflags=-N.
Similar to #53600, this is a bug in induction variable detection. Just reversing the direction when step is negative in cmd/compile/internal/ssa/loopbce.go (added in CL 104041 ) isn't quite right. The "distance until overflow" isn't preserved under mirroring.
@dr2chase @rasky
This program will loop forever when it shouldn't. You can "fix" it by passing
-gcflags=-N.Similar to #53600, this is a bug in induction variable detection. Just reversing the direction when
stepis negative incmd/compile/internal/ssa/loopbce.go(added in CL 104041 ) isn't quite right. The "distance until overflow" isn't preserved under mirroring.@dr2chase @rasky