-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: does not diagnose constant division by zero #11674
Comments
The spec is not super-clear, but this appears to be a compiler bug: The untyped constants (1e-47, 1e-1000) are converted to float32/complex64 values before the operation, and the conversion results in silent underflow to 0, hence the div-by-zero error. For comparison, in package main ( http://play.golang.org/p/YrUx9sSX3w ) the compiler does exactly that: it converts the untyped 128 into an int8 which is not possible and thus returns an error. |
Analysis: in
Note the call to
here, because For
unfortunately, the
i.e. it moves the value of the real part to
here passes, because rv (the real part) in not zero, and the
lines is not called. I have a simple patch for this (we just need to call |
CL https://golang.org/cl/37891 mentions this issue. |
gc produces an error for c and d, but not for a and b:
gotype produces errors for all 4 variables.
go version devel +9b04852 Sat Jul 11 00:08:50 2015 +0000 linux/amd64
The text was updated successfully, but these errors were encountered: