Skip to content

cmd/compile: building causes a panic: runtime error: index out of range [-1] #47799

Closed

Description

@renthraysk

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

Activity

  1. ALTree commented on Aug 19, 2021

    @ALTree
    Member

    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.

  2. locked and limited conversation to collaborators on Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions