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: interface conversion panic #11540

Closed
dvyukov opened this issue Jul 2, 2015 · 4 comments
Closed

cmd/compile: interface conversion panic #11540

dvyukov opened this issue Jul 2, 2015 · 4 comments
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Jul 2, 2015

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

@ianlancetaylor ianlancetaylor modified the milestones: Gccgo, Go1.6 Jul 10, 2015
@dvyukov
Copy link
Member Author

dvyukov commented Jul 11, 2015

Another reproducer:

package a
var a = complex64(1)/1e-48

@griesemer
Copy link
Contributor

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
Copy link

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

mk0x9 pushed a commit to mk0x9/go that referenced this issue Aug 5, 2015
…'imag'

For golang#11669, golang#11540, golang#11945, golang#11946, golang#11947.

Change-Id: Ifb0053c498cee9f3473c396f9338d82bd856c110
Reviewed-on: https://go-review.googlesource.com/12860
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
@rsc
Copy link
Contributor

rsc commented Dec 5, 2015

Current compiler prints:
/tmp/x.go:3: constant 1e+40 overflows complex64

@rsc rsc closed this as completed Dec 5, 2015
@golang golang locked and limited conversation to collaborators Dec 14, 2016
@rsc rsc removed their assignment Jun 23, 2022
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