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: := assignment in for loop statement throws internal compiler error #20840

Closed
iamsamwood opened this issue Jun 28, 2017 · 1 comment

Comments

@iamsamwood
Copy link

iamsamwood commented Jun 28, 2017

Please answer these questions before submitting your issue. Thanks!

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

package main

import "fmt"

func main() {
	for ; false; j := 1 {
		fmt.Printf("%d", j)
	}
}

https://play.golang.org/p/n2qRCxIsaa

What did you expect to see?

A more descriptive compiler error.

What did you see instead?

tmp/sandbox205983736/main.go:5: internal compiler error: Value live at entry. It shouldn't be. func main, node j, value v52

goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
	/usr/local/go/src/runtime/debug/stack.go:24 +0x79
cmd/compile/internal/gc.Fatalf(0xacd433, 0x40, 0xc420333200, 0x3, 0x3)
	/usr/local/go/src/cmd/compile/internal/gc/subr.go:167 +0x226
cmd/compile/internal/gc.(*ssaExport).Fatalf(0xdcb195, 0x5, 0xacd433, 0x40, 0xc420333200, 0x3, 0x3)
	/usr/local/go/src/cmd/compile/internal/gc/ssa.go:4979 +0x5d
cmd/compile/internal/ssa.(*Config).Fatalf(0xc42034a000, 0xc400000005, 0xacd433, 0x40, 0xc420333200, 0x3, 0x3)
	/usr/local/go/src/cmd/compile/internal/ssa/config.go:343 +0x6e
cmd/compile/internal/gc.(*state).Fatalf(0xc42031c1e0, 0xacd433, 0x40, 0xc420333200, 0x3, 0x3)
	/usr/local/go/src/cmd/compile/internal/gc/ssa.go:286 +0x83
cmd/compile/internal/gc.(*simplePhiState).insertPhis(0xc4203454b0)
	/usr/local/go/src/cmd/compile/internal/gc/phi.go:458 +0x2c5
cmd/compile/internal/gc.(*state).insertPhis(0xc42031c1e0)
	/usr/local/go/src/cmd/compile/internal/gc/phi.go:33 +0x172
cmd/compile/internal/gc.buildssa(0xc42032fa70, 0x0)
	/usr/local/go/src/cmd/compile/internal/gc/ssa.go:174 +0x8ee
cmd/compile/internal/gc.compile(0xc42032fa70)
	/usr/local/go/src/cmd/compile/internal/gc/pgen.go:362 +0x204
cmd/compile/internal/gc.funccompile(0xc42032fa70)
	/usr/local/go/src/cmd/compile/internal/gc/dcl.go:1292 +0xdc
cmd/compile/internal/gc.Main()
	/usr/local/go/src/cmd/compile/internal/gc/main.go:464 +0x1f08
main.main()
	/usr/local/go/src/cmd/compile/main.go:50 +0xfe

System details

tmp/sandbox269629440/main.go:5: internal compiler error: Value live at entry. It shouldn't be. func main, node j, value v49

goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
	/usr/local/go/src/runtime/debug/stack.go:24 +0x79
cmd/compile/internal/gc.Fatalf(0xacd433, 0x40, 0xc420333140, 0x3, 0x3)
	/usr/local/go/src/cmd/compile/internal/gc/subr.go:167 +0x226
cmd/compile/internal/gc.(*ssaExport).Fatalf(0xdcb195, 0x5, 0xacd433, 0x40, 0xc420333140, 0x3, 0x3)
	/usr/local/go/src/cmd/compile/internal/gc/ssa.go:4979 +0x5d
cmd/compile/internal/ssa.(*Config).Fatalf(0xc42034a000, 0xc400000005, 0xacd433, 0x40, 0xc420333140, 0x3, 0x3)
	/usr/local/go/src/cmd/compile/internal/ssa/config.go:343 +0x6e
cmd/compile/internal/gc.(*state).Fatalf(0xc42031c1e0, 0xacd433, 0x40, 0xc420333140, 0x3, 0x3)
	/usr/local/go/src/cmd/compile/internal/gc/ssa.go:286 +0x83
cmd/compile/internal/gc.(*simplePhiState).insertPhis(0xc4203474b0)
	/usr/local/go/src/cmd/compile/internal/gc/phi.go:458 +0x2c5
cmd/compile/internal/gc.(*state).insertPhis(0xc42031c1e0)
	/usr/local/go/src/cmd/compile/internal/gc/phi.go:33 +0x172
cmd/compile/internal/gc.buildssa(0xc42032fa70, 0x0)
	/usr/local/go/src/cmd/compile/internal/gc/ssa.go:174 +0x8ee
cmd/compile/internal/gc.compile(0xc42032fa70)
	/usr/local/go/src/cmd/compile/internal/gc/pgen.go:362 +0x204
cmd/compile/internal/gc.funccompile(0xc42032fa70)
	/usr/local/go/src/cmd/compile/internal/gc/dcl.go:1292 +0xdc
cmd/compile/internal/gc.Main()
	/usr/local/go/src/cmd/compile/internal/gc/main.go:464 +0x1f08
main.main()
	/usr/local/go/src/cmd/compile/main.go:50 +0xfe
@bradfitz
Copy link
Contributor

This is fixed in Go 1.9. (tested with Go tip, a bit after Go 1.9beta2).

@cespare cespare changed the title := assignment in for loop statement throws internal compiler error cmd/compile: := assignment in for loop statement throws internal compiler error Jun 28, 2017
@golang golang locked and limited conversation to collaborators Jun 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants