-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Description
Go version
go version devel go1.22-bb34112d4d Thu Dec 7 17:27:54 2023 +0000 darwin/arm64
What operating system and processor architecture are you using (go env
)?
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/taiwon/Library/Caches/go-build'
GOENV='/Users/taiwon/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/taiwon/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/taiwon/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/taiwon/go/src/github.com/golang/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/taiwon/go/src/github.com/golang/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='devel go1.22-bb34112d4d Thu Dec 7 17:27:54 2023 +0000'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/taiwon/go/src/github.com/tchung1118/test-app/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/t0/jhcv48q51ydbyzqn85y8rsgm0000gn/T/go-build3626636808373952552=/tmp/go-build -gno-record-gcc-switches -fno-common'
What did you do?
I have the following code:
main.go
:
package main
import (
"errors"
"fmt"
)
func main() {
}
// ToFloat64 tries to convert an interface to int64
// it returns 0, error if failed
func ToFloat64(o interface{}) (float64, error) {
switch v := o.(type) {
case int:
return float64(v), nil
case int8:
return float64(v), nil
case int16:
return float64(v), nil
case int32:
return float64(v), nil
case int64:
return float64(v), nil
case float32:
return float64(v), nil
case float64:
return float64(v), nil
default:
return float64(0), errors.New("Failed to convert to float64")
}
}
func someFunc() {
value, err := ToFloat64(int64(5))
fmt.Println(value, err)
value, err = ToFloat64(uint64(5))
fmt.Println(value, err)
}
And I tried to build it with the following command:
~/go/src/github.com/golang/go/bin/go build -gcflags=-race .
What did you expect to see?
I expect the compilation to succeed. (succeeds in go1.21)
What did you see instead?
I see an internal compiler error with the following trace:
./main.go:36:25: internal compiler error: 'someFunc': inconsistent state, num predecessors: 7, num phi args: 7
goroutine 1 [running]:
runtime/debug.Stack()
/Users/taiwon/go/src/github.com/golang/go/src/runtime/debug/stack.go:24 +0x64
cmd/compile/internal/base.FatalfAt({0x474ef8?, 0x140?}, {0x140005bf400, 0x40}, {0x14000627980, 0x3, 0x3})
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/base/print.go:225 +0x1fc
cmd/compile/internal/base.Fatalf(...)
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/base/print.go:194
cmd/compile/internal/ssagen.(*ssafn).Fatalf(0x0?, {0x5fedc0?, 0x140?}, {0x10566599b, 0x3a}, {0x140005fedc0, 0x2, 0x14000474f78?})
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/ssagen/ssa.go:8225 +0x150
cmd/compile/internal/ssa.(*Func).Fatalf(0x140005da340, {0x10566599b, 0x3a}, {0x140005fedc0, 0x2, 0x2})
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/ssa/func.go:742 +0x25c
cmd/compile/internal/ssa.(*Block).Fatalf(...)
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/ssa/block.go:405
cmd/compile/internal/ssa.(*Block).removePhiArg(0x1400053bf50, 0x1400050e5b0, 0x4)
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/ssa/block.go:342 +0xe0
cmd/compile/internal/ssa.(*Block).removeEdge(0x14000622bb0?, 0x6?)
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/ssa/deadcode.go:331 +0x290
cmd/compile/internal/ssa.deadcode(0x140005da340)
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/ssa/deadcode.go:181 +0x1614
cmd/compile/internal/ssa.Compile(0x140005da340)
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/ssa/compile.go:97 +0x94c
cmd/compile/internal/ssagen.buildssa(0x14000470c60, 0x0)
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/ssagen/ssa.go:575 +0x2150
cmd/compile/internal/ssagen.Compile(0x14000470c60, 0x0)
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/ssagen/pgen.go:216 +0x30
cmd/compile/internal/gc.compileFunctions.func5.1(0x1?)
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/gc/compile.go:182 +0x3c
cmd/compile/internal/gc.compileFunctions.func2(0x4?)
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/gc/compile.go:136 +0x28
cmd/compile/internal/gc.compileFunctions.func5({0x140005fe920, 0x3, 0x1058874a0?})
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/gc/compile.go:181 +0x60
cmd/compile/internal/gc.compileFunctions()
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/gc/compile.go:192 +0x1f4
cmd/compile/internal/gc.Main(0x105887330)
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/internal/gc/main.go:303 +0x1274
main.main()
/Users/taiwon/go/src/github.com/golang/go/src/cmd/compile/main.go:57 +0x110
Metadata
Metadata
Assignees
Labels
FrozenDueToAgecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.