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

fmt: Println(1 << 31) panics on playground #10437

Closed
gaal opened this issue Apr 13, 2015 · 1 comment
Closed

fmt: Println(1 << 31) panics on playground #10437

gaal opened this issue Apr 13, 2015 · 1 comment

Comments

@gaal
Copy link

@gaal gaal commented Apr 13, 2015

http://play.golang.org/p/XRZe_kcHav
http://play.golang.org/p/s9SX9Wd-PY

"constant 2147483648 overflows int"

Why doesn't the compiler pick a wider type, then?

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Apr 13, 2015

This is working as intended. The Go spec says that the default type for integer constant expressions is "int", which on the Go playground is a 32-bit type and is unable to exactly represent the constant 1<<31. The compiler isn't picking a wider type because the spec doesn't allow it to.

@mdempsky mdempsky closed this Apr 13, 2015
@mikioh mikioh changed the title fmt.Println(1 << 31) panics on playground fmt: Println(1 << 31) panics on playground Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.