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
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)?
go version go1.8.1 linux/amd64
What operating system and processor architecture are you using (go env)?
I think this is working as intended. It's a side effect of coercing an untyped integer constant math.MaxUint64 to an int while being boxed into the ...interface{} for fmt.Println.
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 int would still have an interesting corner case:
package main
import (
"fmt""math"
)
funcmain() {
fmt.Println(math.MaxUint32)
}
$ GOARCH=amd64 go run main.go
4294967295
$ GOARCH=386 go run main.go
main.go:9: constant 4294967295 overflows int
The reason is again obvious, but I'd expect a bit more "portability" than to choke so easily between 32/64 bits.
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: