You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
Two links:
This compiles and runs successfully through: https://play.golang.org/p/SHkSuvdSoX5
This demonstrates the inconsistent behavior if I use a variable as the denominator: https://play.golang.org/p/_IfEAM4XsQu
What did you expect to see?
I should see the same behavior if I try to use a variable as when I use a constant.
This behaviour is consistent with the spec. The spec forbids constant division by zero, but we have never generated compile-time errors for variables.
Regarding the run-time behaviour of your fist code snippet, note that
the result of a floating-point or complex division by zero is not specified beyond the IEEE-754 standard; whether a run-time panic occurs is implementation-specific.
So not even a crash at run-time is mandatory. Generating an IEEE-754 +Inf is allowed.
ALTree
changed the title
Inconsistent Behavior Dividing by 0.0 using Static vs Variable assignment
spec: inconsistent Behavior Dividing by 0.0 using Static vs Variable assignment
Jan 23, 2018
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8.3 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
Two links:
This compiles and runs successfully through: https://play.golang.org/p/SHkSuvdSoX5
This demonstrates the inconsistent behavior if I use a variable as the denominator: https://play.golang.org/p/_IfEAM4XsQu
What did you expect to see?
I should see the same behavior if I try to use a variable as when I use a constant.
What did you see instead?
Either both lines should fail, or neither should.
Related Issue
#10006
The text was updated successfully, but these errors were encountered: