Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: more incorrect loop variable detection #53663

Closed
randall77 opened this issue Jul 2, 2022 · 1 comment
Closed

cmd/compile: more incorrect loop variable detection #53663

randall77 opened this issue Jul 2, 2022 · 1 comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@randall77
Copy link
Contributor

randall77 commented Jul 2, 2022

This program should terminate after one iteration. Instead, it runs forever.

Related to #53600 #53653

package main

import "math"

//go:noinline
func f(i int64) {
	for j := int64(math.MaxInt64); j <= i-1; j++ {
		if j < 0 {
			break
		}
		println(j)
	}
}

func main() {
	f(math.MinInt64)
}

@dr2chase @rasky

@gopherbot
Copy link

gopherbot commented Jul 2, 2022

Change https://go.dev/cl/415874 mentions this issue: cmd/compile: rework induction variable detector

@dr2chase dr2chase added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 3, 2022
@dmitshur dmitshur added this to the Go1.19 milestone Jul 6, 2022
jproberts pushed a commit to jproberts/go that referenced this issue Aug 10, 2022
Induction variable detection is still not quite right. I've added
another failing test.

Redo the overflow/underflow detector so it is more obviously correct.

Update golang#53600
Fixes golang#53653
Fixes golang#53663

Change-Id: Id95228e282fdbf6bd80b26e1c41d62e935ba08ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/415874
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants