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: evconst changed Type #23414

Closed
dsnet opened this issue Jan 11, 2018 · 6 comments
Closed

cmd/compile: internal compiler error: evconst changed Type #23414

dsnet opened this issue Jan 11, 2018 · 6 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dsnet
Copy link
Member

dsnet commented Jan 11, 2018

Was playing around with #23413 and managed to get this compiler error.

var s = struct {
	t1 struct{}
	_  int
	t2 struct{}
}{}
print(&s.t1 == &s.t2)

This crashes on Go1.9 and on:

# command-line-arguments
<autogenerated>:1:0: internal compiler error: evconst changed Type: true && true had type bool, now untyped bool

goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
	/usr/local/go.tip/src/runtime/debug/stack.go:24 +0xa7
cmd/compile/internal/gc.Fatalf(0xc26e98, 0x2c, 0xc42037cc80, 0x3, 0x3)
	/usr/local/go.tip/src/cmd/compile/internal/gc/subr.go:182 +0x1f2
cmd/compile/internal/gc.walkexpr(0xc42033e600, 0xc42033e690, 0xc42050cfc0)
	/usr/local/go.tip/src/cmd/compile/internal/gc/walk.go:1745 +0xae0
cmd/compile/internal/gc.walkexprlist(0xc420514278, 0x1, 0x1, 0xc42033e690)
	/usr/local/go.tip/src/cmd/compile/internal/gc/walk.go:378 +0x50
cmd/compile/internal/gc.walkstmt(0xc42033e680, 0xc42037cf01)
	/usr/local/go.tip/src/cmd/compile/internal/gc/walk.go:292 +0x11f
cmd/compile/internal/gc.walkstmtlist(0xc420514288, 0x1, 0x1)
	/usr/local/go.tip/src/cmd/compile/internal/gc/walk.go:78 +0x46
cmd/compile/internal/gc.walk(0xc4204b9500)
	/usr/local/go.tip/src/cmd/compile/internal/gc/walk.go:62 +0x3a1
cmd/compile/internal/gc.compile(0xc4204b9500)
	/usr/local/go.tip/src/cmd/compile/internal/gc/pgen.go:203 +0xae
cmd/compile/internal/gc.funccompile(0xc4204b9500)
	/usr/local/go.tip/src/cmd/compile/internal/gc/dcl.go:1040 +0xad
cmd/compile/internal/gc.geneq(0xc4205326c0, 0xc420374fc0)
	/usr/local/go.tip/src/cmd/compile/internal/gc/alg.go:503 +0x790
cmd/compile/internal/gc.dalgsym(0xc420374fc0, 0xffffffffffffffff)
	/usr/local/go.tip/src/cmd/compile/internal/gc/reflect.go:1685 +0x5c4
cmd/compile/internal/gc.dcommontype(0xc42053a230, 0x0, 0xc420374fc0, 0xc420333418)
	/usr/local/go.tip/src/cmd/compile/internal/gc/reflect.go:856 +0xa3
cmd/compile/internal/gc.dtypesym(0xc420374fc0, 0xc420343de0)
	/usr/local/go.tip/src/cmd/compile/internal/gc/reflect.go:1360 +0xd19
cmd/compile/internal/gc.dumpsignats()
	/usr/local/go.tip/src/cmd/compile/internal/gc/reflect.go:1511 +0x341
cmd/compile/internal/gc.dumpobj1(0x7fff19d0ace3, 0x23, 0x3)
	/usr/local/go.tip/src/cmd/compile/internal/gc/obj.go:139 +0x2a1
cmd/compile/internal/gc.dumpobj()
	/usr/local/go.tip/src/cmd/compile/internal/gc/obj.go:50 +0x51
cmd/compile/internal/gc.Main(0xc2e5f8)
	/usr/local/go.tip/src/cmd/compile/internal/gc/main.go:683 +0x2b0e
main.main()
	/usr/local/go.tip/src/cmd/compile/main.go:49 +0x89

\cc @randall77 @mdempsky

@dsnet dsnet added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 11, 2018
@dsnet dsnet added this to the Go1.11 milestone Jan 11, 2018
@dsnet
Copy link
Member Author

dsnet commented Jan 11, 2018

Since this is broken on Go1.9, the fix can probably wait till Go1.11.

@bradfitz
Copy link
Contributor

Works with Go 1.8, though.

@namusyaka
Copy link
Member

I guess the issue has been occured since 26be4b9.
cc @josharian

@gopherbot
Copy link

Change https://golang.org/cl/91316 mentions this issue: cmd/compile: avoid unexpected changing untyped bool by evconst

@mdempsky
Copy link
Member

The test case can be further minimized to just:

package p

type t struct {
        t1 struct{}
        _  int
        t2 struct{}
}

The problem is this is generating a function like

func eq.t(p, q *t) bool {
    return p.t1 == q.t1 && p.t2 == q.t2
}

This is getting optimized to

    return true && true

but for some reason the true nodes have type untyped bool, but the overall true && true expression has type bool. When we apply evconst to this expression, its type changes from bool to untyped bool.

@gopherbot
Copy link

Change https://golang.org/cl/94022 mentions this issue: cmd/compile: fix typechecking of untyped boolean expressions

@golang golang locked and limited conversation to collaborators Feb 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants