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: internal compiler error: unhandled OCONV INT -> TUNSAFEPTR #16317

Closed
ghost opened this issue Jul 11, 2016 · 6 comments
Closed

cmd/compile: internal compiler error: unhandled OCONV INT -> TUNSAFEPTR #16317

ghost opened this issue Jul 11, 2016 · 6 comments
Milestone

Comments

@ghost
Copy link

ghost commented Jul 11, 2016

Please answer these questions before submitting your issue. Thanks!

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

go version go1.7rc1 windows/amd64

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

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=c:\work\go
set GORACE=
set GOROOT=c:\go
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=c:\temp\go-build284024486=/tmp/go-build -gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1

  1. What did you do?

Compiling.

module $GOPATH/tst/tst.go

package tst
import "unsafe"
func NullPtr() unsafe.Pointer { return unsafe.Pointer(uintptr(0)) }

module $GOPATH/main.go

package main
import "tst"
func main() { _ = tst.NullPtr() }
  1. What did you expect to see?
    Successfull compilation
  2. What did you see instead?
# command-line-arguments
.\main.go:2: cannot convert 0 (type int) to type unsafe.Pointer
.\main.go:3: internal compiler error: unhandled OCONV INT -> TUNSAFEPTR

goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
    c:/go/src/runtime/debug/stack.go:24 +0x80
cmd/compile/internal/gc.Fatalf(0x912f52, 0x18, 0xc042044840, 0x2, 0x2)
    c:/go/src/cmd/compile/internal/gc/subr.go:165 +0x24f
cmd/compile/internal/gc.(*ssaExport).Unimplementedf(0xb72a8a, 0x3, 0x912f52, 0x18, 0xc042044840, 0x2, 0x2)
    c:/go/src/cmd/compile/internal/gc/ssa.go:4446 +0x145
cmd/compile/internal/ssa.(*Config).Unimplementedf(0xc042428000, 0xc000000003, 0x912f52, 0x18, 0xc042044840, 0x2, 0x2)
    c:/go/src/cmd/compile/internal/ssa/config.go:202 +0x78
cmd/compile/internal/gc.(*state).Unimplementedf(0xc04206e360, 0x912f52, 0x18, 0xc042044840, 0x2, 0x2)
    c:/go/src/cmd/compile/internal/gc/ssa.go:338 +0x8a
cmd/compile/internal/gc.(*state).expr(0xc04206e360, 0xc04240cc60, 0x0)
    c:/go/src/cmd/compile/internal/gc/ssa.go:1707 +0x5876
cmd/compile/internal/gc.(*state).stmt(0xc04206e360, 0xc04240d5f0)
    c:/go/src/cmd/compile/internal/gc/ssa.go:724 +0x435
cmd/compile/internal/gc.(*state).stmtList(0xc04206e360, 0xc0420446e0)
    c:/go/src/cmd/compile/internal/gc/ssa.go:542 +0x65
cmd/compile/internal/gc.(*state).stmt(0xc04206e360, 0xc04240d710)
    c:/go/src/cmd/compile/internal/gc/ssa.go:561 +0xd8
cmd/compile/internal/gc.(*state).stmts(0xc04206e360, 0xc042044660)
    c:/go/src/cmd/compile/internal/gc/ssa.go:535 +0x65
cmd/compile/internal/gc.buildssa(0xc04240c360, 0x0)
    c:/go/src/cmd/compile/internal/gc/ssa.go:182 +0x6bf
cmd/compile/internal/gc.compile(0xc04240c360)
    c:/go/src/cmd/compile/internal/gc/pgen.go:405 +0x136a
cmd/compile/internal/gc.funccompile(0xc04240c360)
    c:/go/src/cmd/compile/internal/gc/dcl.go:1287 +0x18d
cmd/compile/internal/gc.Main()
    c:/go/src/cmd/compile/internal/gc/main.go:467 +0x1a00
cmd/compile/internal/amd64.Main()
    c:/go/src/cmd/compile/internal/amd64/galign.go:93 +0x301
main.main()
    c:/go/src/cmd/compile/main.go:33 +0x2aa

Notes:
Go 1.6.2 produces same compilation error but without internal compiler error
Compilation error disappers if function NullPtr moved from package to main module:

package main
import "unsafe"
func NullPtr() unsafe.Pointer { return unsafe.Pointer(uintptr(0)) }
func main() { _ = NullPtr() }
@ianlancetaylor ianlancetaylor changed the title internal compiler error: unhandled OCONV INT -> TUNSAFEPTR cmd/compile: internal compiler error: unhandled OCONV INT -> TUNSAFEPTR Jul 11, 2016
@ianlancetaylor ianlancetaylor added this to the Go1.8 milestone Jul 11, 2016
@ianlancetaylor
Copy link
Contributor

Not a regression so marking as Go1.8.

@randall77
Copy link
Contributor

Might be related to #16306 .

@martisch
Copy link
Contributor

martisch commented Aug 21, 2016

looking into this.

During inlining in mkinlcall1 fn.func.Inl contains return @"unsafe".Pointer(int(0x0)) so somewhere the conversion got lost in binary export->import and ssa expr() later trips on the OCONV from INT to TUNSAFEPTR generated by the inlining. Seems like maybe in bimport.go node() case OLITERAL we could handle unsafe.Pointer specially.

        if !typ.IsUntyped() {
            if typ.IsUnsafePtr() {
                conv := Nod(OCALL, typenod(Types[TUINTPTR]), nil)
                conv.List.Set1(n)
                n = conv
            }

@josharian
Copy link
Contributor

cc @griesemer and @mdempsky for import/export. They're the right reviewers for the CL if/when it comes.

@martisch
Copy link
Contributor

@josharian saw this to late but i added @griesemer on cc anyway. We can fix this in many ways but i think at import is cleaner because it seems to happen only with export + import.

@gopherbot
Copy link

CL https://golang.org/cl/27441 mentions this issue.

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

5 participants