cmd/compile: mishandles int->complex conversion (original) (raw)

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