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 STRUCT -> STRUCT #17111

Closed
dsnet opened this issue Sep 14, 2016 · 5 comments
Closed

cmd/compile: internal compiler error: unhandled OCONV STRUCT -> STRUCT #17111

dsnet opened this issue Sep 14, 2016 · 5 comments
Milestone

Comments

@dsnet
Copy link
Member

dsnet commented Sep 14, 2016

Commit dfc56a4 caused a regression where the following code fails to compile:

package main

import (
    "testing"
    "time"
)

type Value interface{}

type DateTime time.Time

var _ Value = DateTime(time.Time{})

var (
    date1Time = time.Date(2014, 2, 3, 1, 2, 3, 400000000, time.UTC)
    date1     = DateTime(date1Time)
)

var dateTimeNotSupported = []struct {
    in  Value
    out Value
}{{in: date1, out: nil}}

func Test(*testing.T) {}

On the commit in question, I see the following:

# command-line-arguments
./main_test.go:24: cannot use date1Time (type time.Time) as type DateTime in assignment
./main_test.go:24: internal compiler error: unhandled OCONV STRUCT -> STRUCT

goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
    /home/rawr/Projects/go/src/runtime/debug/stack.go:24 +0x79
cmd/compile/internal/gc.Fatalf(0xab7efc, 0x18, 0xc42053e260, 0x2, 0x2)
    /home/rawr/Projects/go/src/cmd/compile/internal/gc/subr.go:165 +0x22f
cmd/compile/internal/gc.(*ssaExport).Fatalf(0xde9a9a, 0x18, 0xab7efc, 0x18, 0xc42053e260, 0x2, 0x2)
    /home/rawr/Projects/go/src/cmd/compile/internal/gc/ssa.go:4772 +0x5d
cmd/compile/internal/ssa.(*Config).Fatalf(0xc4204dc000, 0xc400000018, 0xab7efc, 0x18, 0xc42053e260, 0x2, 0x2)
    /home/rawr/Projects/go/src/cmd/compile/internal/ssa/config.go:292 +0x6e
cmd/compile/internal/gc.(*state).Fatalf(0xc4203f87e0, 0xab7efc, 0x18, 0xc42053e260, 0x2, 0x2)
    /home/rawr/Projects/go/src/cmd/compile/internal/gc/ssa.go:280 +0x83
cmd/compile/internal/gc.(*state).expr(0xc4203f87e0, 0xc42053d560, 0x0)
    /home/rawr/Projects/go/src/cmd/compile/internal/gc/ssa.go:1698 +0x428b
cmd/compile/internal/gc.(*state).stmt(0xc4203f87e0, 0xc42053c630)
    /home/rawr/Projects/go/src/cmd/compile/internal/gc/ssa.go:678 +0x409
cmd/compile/internal/gc.(*state).stmts(0xc4203f87e0, 0xc4204b9fe0)
    /home/rawr/Projects/go/src/cmd/compile/internal/gc/ssa.go:481 +0x5e
cmd/compile/internal/gc.buildssa(0xc42053c870, 0x0)
    /home/rawr/Projects/go/src/cmd/compile/internal/gc/ssa.go:126 +0x67f
cmd/compile/internal/gc.compile(0xc42053c870)
    /home/rawr/Projects/go/src/cmd/compile/internal/gc/pgen.go:402 +0x209
cmd/compile/internal/gc.funccompile(0xc42053c870)
    /home/rawr/Projects/go/src/cmd/compile/internal/gc/dcl.go:1260 +0x179
cmd/compile/internal/gc.fninit(0xc4204bc300, 0x7, 0x8)
    /home/rawr/Projects/go/src/cmd/compile/internal/gc/init.go:182 +0xb8f
cmd/compile/internal/gc.Main()
    /home/rawr/Projects/go/src/cmd/compile/internal/gc/main.go:480 +0x23f5
cmd/compile/internal/amd64.Main()
    /home/rawr/Projects/go/src/cmd/compile/internal/amd64/galign.go:93 +0x2fa
main.main()
    /home/rawr/Projects/go/src/cmd/compile/main.go:33 +0x279

I expect the test to compile and pass.

/cc @josharian, @randall77, @mdempsky

@dsnet dsnet added this to the Go1.8 milestone Sep 14, 2016
@josharian
Copy link
Contributor

Looking. Simpler form:

package main

type I int

var (
    i int
    x = I(i)

    e interface{} = x
)

@josharian
Copy link
Contributor

Thanks, @dsnet. Getting these issues filed quickly is super helpful. Please let me know whether CL 29213 fixes the original code.

@bradfitz
Copy link
Contributor

Yeah, thanks @dsnet!

@gopherbot
Copy link

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

josharian added a commit to josharian/go that referenced this issue Sep 15, 2016
staticassign unwraps all CONVNOPs.
However, in the included test, we need the
CONVNOP for everything to typecheck.
Stop unwrapping unnecessarily.

The code we generate for this example is
suboptimal, but that's not new; see golang#17113.

Fixes golang#17111.

Change-Id: I29532787a074a6fe19a5cc53271eb9c84bf1b576
@dsnet
Copy link
Member Author

dsnet commented Sep 15, 2016

I confirm that this fixed the broken target. Thanks!

@dsnet dsnet reopened this Sep 15, 2016
@dsnet dsnet closed this as completed Sep 15, 2016
@golang golang locked and limited conversation to collaborators Sep 15, 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

4 participants