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

Comments

Projects
None yet
5 participants
@dsnet
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 label Jan 11, 2018

@dsnet dsnet added this to the Go1.11 milestone Jan 11, 2018

@dsnet

This comment has been minimized.

Show comment
Hide comment
@dsnet

dsnet Jan 11, 2018

Member

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

Member

dsnet commented Jan 11, 2018

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

@bradfitz

This comment has been minimized.

Show comment
Hide comment
@bradfitz

bradfitz Jan 11, 2018

Member

Works with Go 1.8, though.

Member

bradfitz commented Jan 11, 2018

Works with Go 1.8, though.

@namusyaka

This comment has been minimized.

Show comment
Hide comment
@namusyaka

namusyaka Jan 31, 2018

Member

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

Member

namusyaka commented Jan 31, 2018

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

@gopherbot

This comment has been minimized.

Show comment
Hide comment
@gopherbot

gopherbot Feb 1, 2018

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

gopherbot commented Feb 1, 2018

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

@mdempsky

This comment has been minimized.

Show comment
Hide comment
@mdempsky

mdempsky Feb 14, 2018

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.

Member

mdempsky commented Feb 14, 2018

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

This comment has been minimized.

Show comment
Hide comment
@gopherbot

gopherbot Feb 14, 2018

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

gopherbot commented Feb 14, 2018

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

@gopherbot gopherbot closed this in d3f6d11 Feb 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment