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: failure to diagnose invalid conversion to complex64 #11590

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

cmd/compile: failure to diagnose invalid conversion to complex64 #11590

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

Comments

@dvyukov
Copy link
Member

dvyukov commented Jul 4, 2015

gc successfully compiles the following program:

package a
var a = complex64(6)/774516156475830989403545856475830078125

while both gccgo and go/types reject it with:

error: complex real part overflow
774516156475830989403545856475830078125 (untyped int constant) overflows complex64

go version devel +40a1516 Fri Jul 3 03:08:40 2015 +0000 linux/amd64

@dvyukov
Copy link
Member Author

dvyukov commented Jul 4, 2015

@griesemer

@griesemer
Copy link
Contributor

I don't believe this is a gc bug. First of all, the conversion is not illegal - an untyped int constant can be converted into a complex value. The complaints are about overflow. But the value 774516156475830989403545856475830078125 is converted into a float64 w/o problem:

package a
var x float64 = 774516156475830989403545856475830078125

Making this a go/types bug.

@griesemer griesemer changed the title cmd/compile: does illegal int->complex conversion go/types: invalid error message for valid conversion to complex64 Jul 4, 2015
@griesemer griesemer assigned griesemer and unassigned rsc Jul 4, 2015
@griesemer
Copy link
Contributor

Never mind - my bad! It's complex64 - not complex128! (I hate these names).

Indeed, "var _ float32 = 774516156475830989403545856475830078125" is not valid because the number is too large for any float32, and thus too large for any complex64 component.

gc should not accept this. Changing back to gc bug. Sorry.

@griesemer griesemer changed the title go/types: invalid error message for valid conversion to complex64 cmd/compile: invalid error message for valid conversion to complex64 Jul 9, 2015
@griesemer griesemer assigned rsc and unassigned griesemer Jul 9, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jul 10, 2015
@rsc
Copy link
Contributor

rsc commented Nov 4, 2015

CL forthcoming.

@rsc rsc changed the title cmd/compile: invalid error message for valid conversion to complex64 cmd/compile: failure to diagnose invalid conversion to complex64 Nov 4, 2015
@gopherbot
Copy link

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

@rsc rsc closed this as completed in 2c11164 Nov 16, 2015
@golang golang locked and limited conversation to collaborators Nov 16, 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