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

go1.18-dev: panic: <nil> not an Int calling unsafe.Sizeof on a generic T #47900

Closed
kylelemons opened this issue Aug 23, 2021 · 2 comments
Closed

Comments

@kylelemons
Copy link
Contributor

kylelemons commented Aug 23, 2021

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

$ go version
go version devel go1.18-86ee892 Sun Aug 22 23:49:55 2021 +0000 windows/amd64

Does this issue reproduce with the latest release?

No -- this is a panic only in gotip related to type parameters and unsafe (yes, yes, I know)

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

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\kyle\AppData\Local\go-build
set GOENV=C:\Users\kyle\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\kyle\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\kyle\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\kyle\sdk\gotip
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\kyle\sdk\gotip\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=devel go1.18-86ee892 Sun Aug 22 23:49:55 2021 +0000
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=C:\Users\kyle\dev\generics_exp\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\kyle\AppData\Local\Temp\go-build4275696402=/tmp/go-build -gno-record-gcc-switches
GOROOT/bin/go version: go version devel go1.18-86ee892 Sun Aug 22 23:49:55 2021 +0000 windows/amd64
GOROOT/bin/go tool compile -V: compile version devel go1.18-86ee892 Sun Aug 22 23:49:55 2021 +0000

What did you do?

go.mod:

module repro

go 1.18

repro.go:

//go:build go1.18

package repro

import (
	"unsafe"
)

func Breaks[T any](t T){
	_ = unsafe.Sizeof(t)
}

What did you expect to see?

I shouldn't be able to make the compiler panic

This seems like it might be a known issue or a pending TODO (apologies if so), but since I don't usually expect the compiler to be able to panic, I figured I'd file it just in case.

What did you see instead?

$ gotip build ./repro
# generics_exp/repro
panic: <nil> not an Int

goroutine 1 [running]:
go/constant.Int64Val({0x0, 0x0})
        C:/Users/kyle/sdk/gotip/src/go/constant/value.go:504 +0x119
cmd/compile/internal/noder.(*irgen).validateBuiltin(0xc00016a300, {0xc00012b18a, 0x6}, 0xc000159740)
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/noder/validate.go:84 +0xd7
cmd/compile/internal/noder.(*irgen).validate(0xc00016a300, {0xe249c0, 0xc000159740})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/noder/validate.go:70 +0x157
cmd/compile/internal/noder.(*irgen).generate.func1({0xe249c0, 0xc000159740})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/noder/irgen.go:259 +0x30
cmd/compile/internal/syntax.Crawl.func1({0xe249c0, 0xc000159740})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/syntax/walk.go:41 +0x30
cmd/compile/internal/syntax.inspector.Visit(0xc000108c80, {0xe249c0, 0xc000159740})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/syntax/walk.go:24 +0x31
cmd/compile/internal/syntax.walker.node({{0xe21d60, 0xc000108c80}}, {0xe249c0, 0xc000159740})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/syntax/walk.go:76 +0x6b
cmd/compile/internal/syntax.walker.node({{0xe21d60, 0xc000108c80}}, {0xe248f8, 0xc000159780})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/syntax/walk.go:253 +0x2cd
cmd/compile/internal/syntax.walker.stmtList({{0xe21d60, 0xc000108c80}}, {0xc000108b70, 0x1, 0xc00041c0c0})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/syntax/walk.go:348 +0x91
cmd/compile/internal/syntax.walker.node({{0xe21d60, 0xc000108c80}}, {0xe24970, 0xc000159700})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/syntax/walk.go:238 +0x13f2
cmd/compile/internal/syntax.walker.node({{0xe21d60, 0xc000108c80}}, {0xe24bf0, 0xc0001678c0})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/syntax/walk.go:125 +0x949
cmd/compile/internal/syntax.walker.declList({{0xe21d60, 0xc000108c80}}, {0xc00041c1c0, 0x2, 0xc00014d6d8})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/syntax/walk.go:336 +0x91
cmd/compile/internal/syntax.walker.node({{0xe21d60, 0xc000108c80}}, {0xe24ba0, 0xc000433a40})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/syntax/walk.go:85 +0xfee
cmd/compile/internal/syntax.Walk(...)
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/syntax/walk.go:57
cmd/compile/internal/syntax.Inspect(...)
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/syntax/walk.go:18
cmd/compile/internal/syntax.Crawl({0xe24ba0, 0xc000433a40}, 0xc000108c70)
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/syntax/walk.go:40 +0x75
cmd/compile/internal/noder.(*irgen).generate(0xc00016a300, {0xc00014e450, 0x1, 0xc0003966c0})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/noder/irgen.go:258 +0x1dd
cmd/compile/internal/noder.check2({0xc00014e450, 0x1, 0x1})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/noder/irgen.go:92 +0x16d
cmd/compile/internal/noder.LoadPackage({0xc00015c0f0, 0x1, 0x0})
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/noder/noder.go:90 +0x365
cmd/compile/internal/gc.Main(0xcf0d38)
        C:/Users/kyle/sdk/gotip/src/cmd/compile/internal/gc/main.go:190 +0xaf3
main.main()
        C:/Users/kyle/sdk/gotip/src/cmd/compile/main.go:55 +0xdd
@tdakkota
Copy link

Seems like duplicate of #47716.

@martisch
Copy link
Contributor

Closing as duplicate.

@golang golang locked and limited conversation to collaborators Aug 23, 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

4 participants