golang/go

cmd/compile: mishandles int->complex conversion

dvyukov opened this issue · 2 comments

Output of the following program

package main
var a = complex64(4e38)
func main() {
    println(a)
}

is (when built with gc compiler):

(+Inf+0.000000e+000i)

This is wrong. The conversion must not be compiled as the constant does not fit into complex64.

The following program hangs infinitely in go tool compile:

package main

func main() {
    var a = complex64(4e38)
    println(a)
}

Seems to be the same issue.

go version devel +514014c Thu Jun 18 15:54:35 2015 +0200 linux/amd64

Probably the same issue:

package main
var a = complex64(0)/700000000000000000000000000000000000000

must not be compiled, but gc compiles successfully.

rsc commented

Dup of #11590.