golang / go

The Go programming language

Home Page:https://go.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cmd/compile: mishandles int->complex conversion

dvyukov opened this issue · 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.

Dup of #11590.