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: building causes a panic: runtime error: index out of range [-1] #47799

Closed
renthraysk opened this issue Aug 18, 2021 · 1 comment
Closed

Comments

@renthraysk
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.17 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

package main

import (
	"io"
)

type Writer interface {
	io.Writer
	io.StringWriter
	io.ByteWriter
}

func writeString[T Writer](w T, s string) {
	w.WriteString(s)
}

func WriteString(w Writer, s string) {
	writeString[Writer](w, s)
}

func main() {
}

Attempting to build with go build -gcflags="-G=3" main.go

What did you expect to see?

No panic

What did you see instead?

# command-line-arguments
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
cmd/compile/internal/ssagen.(*state).peekPos(...)
	/usr/local/go/src/cmd/compile/internal/ssagen/ssa.go:1061
cmd/compile/internal/ssagen.(*state).pushLine(0xc000150200, {0x44cb14, 0x0})
	/usr/local/go/src/cmd/compile/internal/ssagen/ssa.go:1043 +0x147
cmd/compile/internal/ssagen.buildssa(0xc00001eb00, 0x0)
	/usr/local/go/src/cmd/compile/internal/ssagen/ssa.go:420 +0x497
cmd/compile/internal/ssagen.Compile(0xc00001eb00, 0xc0000c6d00)
	/usr/local/go/src/cmd/compile/internal/ssagen/pgen.go:165 +0x4c
cmd/compile/internal/gc.compileFunctions.func4.1(0x1)
	/usr/local/go/src/cmd/compile/internal/gc/compile.go:153 +0x3a
cmd/compile/internal/gc.compileFunctions.func2(0x0)
	/usr/local/go/src/cmd/compile/internal/gc/compile.go:125 +0x1e
cmd/compile/internal/gc.compileFunctions.func4({0xc0000c6ca0, 0x4, 0x4})
	/usr/local/go/src/cmd/compile/internal/gc/compile.go:152 +0x53
cmd/compile/internal/gc.compileFunctions()
	/usr/local/go/src/cmd/compile/internal/gc/compile.go:163 +0x162
cmd/compile/internal/gc.Main(0xd16450)
	/usr/local/go/src/cmd/compile/internal/gc/main.go:287 +0xf3a
main.main()
	/usr/local/go/src/cmd/compile/main.go:55 +0xdd
@ALTree
Copy link
Member

ALTree commented Aug 19, 2021

I don't think you're supposed to use -G=3 on 1.17. The dev.tyeparams branch was merged into master after the release. -G=3 in 1.17 has a lot of bugs and it's not supposed to be used at all, in general.

If you want to experiment with generics, use -G=3 with tip.

Anyway this is fixed on tip, so closing here.

@ALTree ALTree closed this as completed Aug 19, 2021
@golang golang locked and limited conversation to collaborators Aug 19, 2022
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