cmd/compile: interface conversion panic
dvyukov opened this issue · 4 comments
dvyukov commented
compile crashes on the following program:
package a
var a = 1e20/complex64(1e-20)
panic: interface conversion: interface {} is *gc.Mpcplx, not *gc.Mpflt
goroutine 1 [running]:
cmd/compile/internal/gc.overflow(0x778880, 0xc8201d6dc0, 0xc8200e08c0)
go/src/cmd/compile/internal/gc/const.go:449 +0x55f
cmd/compile/internal/gc.evconst(0xc8201d47e0)
go/src/cmd/compile/internal/gc/const.go:1074 +0x420
cmd/compile/internal/gc.typecheck1(0xc8200f6d20, 0x4)
go/src/cmd/compile/internal/gc/typecheck.go:2215 +0x44c
cmd/compile/internal/gc.typecheck(0xc8201d4878, 0x4, 0x5f41c2)
go/src/cmd/compile/internal/gc/typecheck.go:202 +0x939
cmd/compile/internal/gc.typecheckas(0xc8201d4870)
go/src/cmd/compile/internal/gc/typecheck.go:3320 +0xae
cmd/compile/internal/gc.typecheck1(0xc8200f79f8, 0x2)
go/src/cmd/compile/internal/gc/typecheck.go:2055 +0x490b
cmd/compile/internal/gc.typecheck(0xc8201a5760, 0x2, 0x0)
go/src/cmd/compile/internal/gc/typecheck.go:202 +0x939
cmd/compile/internal/gc.Main()
go/src/cmd/compile/internal/gc/lex.go:385 +0x2126
cmd/compile/internal/amd64.Main()
go/src/cmd/compile/internal/amd64/galign.go:127 +0x58d
main.main()
go/src/cmd/compile/main.go:26 +0x189
go version devel +bb7e665 Tue Jun 30 07:42:37 2015 +0000 linux/amd64
dvyukov commented
Another reproducer:
package a
var a = complex64(1)/1e-48
griesemer commented
Possibly related, but simpler:
package main
const _ = real(1e1000i)
=>
$ go build x.go
# command-line-arguments
panic: interface conversion: interface {} is *gc.Mpcplx, not *gc.Mpflt
(same crash for imag instead of real).
The issue here seems to be that 1e1000 cannot be represented as a float64; and it appears that real and imag don't work for untyped constants outside the float64 range. This is in contrast to complex, and probably should be fixed. It's also unclear from the spec.
gopherbot commented
CL https://golang.org/cl/12860 mentions this issue.
rsc commented
Current compiler prints:
/tmp/x.go:3: constant 1e+40 overflows complex64