-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: error if trying to print constant > int
#20108
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
Comments
I think this is working as intended. It's a side effect of coercing an untyped integer constant |
I guess the compiler needs to make some reproducible decision as to what to box the constant to and can't just pick whatever is the best based on value. That being said, boxing to package main
import (
"fmt"
"math"
)
func main() {
fmt.Println(math.MaxUint32)
}
The reason is again obvious, but I'd expect a bit more "portability" than to choke so easily between 32/64 bits. |
Anyway, if you think it works as intended feel free to close :) At least you have a new slide for your quiz collection @davecheney ;) |
The spec is the spec is the spec, https://golang.org/ref/spec#Constants |
This is mostly a funky error that got me surprised when I saw it. It's of course trivial to work around but I though it could be worth a question whether it's working as intended or not.
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
https://play.golang.org/p/5GARX4Q2Tc
What did you expect to see?
18446744073709551615
What did you see instead?
tmp/sandbox131021564/main.go:9: constant 18446744073709551615 overflows int
The text was updated successfully, but these errors were encountered: